Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367)
Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org> Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
This commit is contained in:
parent
51ff4970ec
commit
fed2d81c44
427 changed files with 2043 additions and 2046 deletions
|
@ -69,7 +69,7 @@ func TestShadowPassword(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, k := range kases {
|
||||
assert.EqualValues(t, k.Result, shadowPassword(k.Provider, k.CfgItem))
|
||||
assert.Equal(t, k.Result, shadowPassword(k.Provider, k.CfgItem))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -512,7 +512,8 @@ func createAndHandleCreatedUser(ctx *context.Context, tpl base.TplName, form any
|
|||
func createUserInContext(ctx *context.Context, tpl base.TplName, form any, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) (ok bool) {
|
||||
if err := user_model.CreateUser(ctx, u, overwrites); err != nil {
|
||||
if allowLink && (user_model.IsErrUserAlreadyExist(err) || user_model.IsErrEmailAlreadyUsed(err)) {
|
||||
if setting.OAuth2Client.AccountLinking == setting.OAuth2AccountLinkingAuto {
|
||||
switch setting.OAuth2Client.AccountLinking {
|
||||
case setting.OAuth2AccountLinkingAuto:
|
||||
var user *user_model.User
|
||||
user = &user_model.User{Name: u.Name}
|
||||
hasUser, err := user_model.GetUser(ctx, user)
|
||||
|
@ -528,7 +529,7 @@ func createUserInContext(ctx *context.Context, tpl base.TplName, form any, u *us
|
|||
// TODO: probably we should respect 'remember' user's choice...
|
||||
linkAccount(ctx, user, *gothUser, true)
|
||||
return false // user is already created here, all redirects are handled
|
||||
} else if setting.OAuth2Client.AccountLinking == setting.OAuth2AccountLinkingLogin {
|
||||
case setting.OAuth2AccountLinkingLogin:
|
||||
showLinkingLogin(ctx, *gothUser)
|
||||
return false // user will be created only after linking login
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ func TestNewAccessTokenResponse_OIDCToken(t *testing.T) {
|
|||
assert.Equal(t, "user5", oidcToken.PreferredUsername)
|
||||
assert.Equal(t, "https://try.gitea.io/user5", oidcToken.Profile)
|
||||
assert.Equal(t, "https://try.gitea.io/assets/img/avatar_default.png", oidcToken.Picture)
|
||||
assert.Equal(t, "", oidcToken.Website)
|
||||
assert.Empty(t, oidcToken.Website)
|
||||
assert.Equal(t, timeutil.TimeStamp(0), oidcToken.UpdatedAt)
|
||||
assert.Equal(t, "user5@example.com", oidcToken.Email)
|
||||
assert.True(t, oidcToken.EmailVerified)
|
||||
|
|
|
@ -60,8 +60,8 @@ func Members(ctx *context.Context) {
|
|||
}
|
||||
|
||||
pager := context.NewPagination(int(total), setting.UI.MembersPagingNum, page, 5)
|
||||
opts.ListOptions.Page = page
|
||||
opts.ListOptions.PageSize = setting.UI.MembersPagingNum
|
||||
opts.Page = page
|
||||
opts.PageSize = setting.UI.MembersPagingNum
|
||||
members, membersIsPublic, err := organization.FindOrgMembers(ctx, opts)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetMembers", err)
|
||||
|
|
|
@ -184,7 +184,7 @@ func (kase *testCase) doTest(t *testing.T) {
|
|||
cmt := issue.Comments[c]
|
||||
t.Logf("%v %v %v\n", cmt.Type, cmt.CreatedUnix, cmt.Content)
|
||||
}
|
||||
assert.EqualValues(t, len(after), len(issue.Comments))
|
||||
assert.Len(t, issue.Comments, len(after))
|
||||
t.Fail()
|
||||
return
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ func (kase *testCase) doTest(t *testing.T) {
|
|||
l.AssigneeTeamID = 0
|
||||
}
|
||||
|
||||
assert.EqualValues(t, (after)[c], issue.Comments[c],
|
||||
assert.Equal(t, (after)[c], issue.Comments[c],
|
||||
"Comment %v is not equal", c,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ func ServeAttachment(ctx *context.Context, uuid string) {
|
|||
}
|
||||
|
||||
if repository == nil { // If not linked
|
||||
if !(ctx.IsSigned && attach.UploaderID == ctx.Doer.ID) { // We block if not the uploader
|
||||
if !ctx.IsSigned || attach.UploaderID != ctx.Doer.ID { // We block if not the uploader
|
||||
ctx.Error(http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -597,7 +597,7 @@ func PrepareCompareDiff(
|
|||
config := unit.PullRequestsConfig()
|
||||
|
||||
if !config.AutodetectManualMerge {
|
||||
allowEmptyPr := !(ci.BaseBranch == ci.HeadBranch && ctx.Repo.Repository.Name == ci.HeadRepo.Name)
|
||||
allowEmptyPr := ci.BaseBranch != ci.HeadBranch || ctx.Repo.Repository.Name != ci.HeadRepo.Name
|
||||
ctx.Data["AllowEmptyPr"] = allowEmptyPr
|
||||
|
||||
return !allowEmptyPr
|
||||
|
@ -660,9 +660,9 @@ func PrepareCompareDiff(
|
|||
|
||||
if len(commits) == 1 {
|
||||
c := commits[0]
|
||||
title = strings.TrimSpace(c.UserCommit.Summary())
|
||||
title = strings.TrimSpace(c.Summary())
|
||||
|
||||
body := strings.Split(strings.TrimSpace(c.UserCommit.Message()), "\n")
|
||||
body := strings.Split(strings.TrimSpace(c.Message()), "\n")
|
||||
if len(body) > 1 {
|
||||
ctx.Data["content"] = strings.Join(body[1:], "\n")
|
||||
}
|
||||
|
@ -952,9 +952,10 @@ func ExcerptBlob(ctx *context.Context) {
|
|||
RightHunkSize: rightHunkSize,
|
||||
},
|
||||
}
|
||||
if direction == "up" {
|
||||
switch direction {
|
||||
case "up":
|
||||
section.Lines = append([]*gitdiff.DiffLine{lineSection}, section.Lines...)
|
||||
} else if direction == "down" {
|
||||
case "down":
|
||||
section.Lines = append(section.Lines, lineSection)
|
||||
}
|
||||
}
|
||||
|
@ -966,7 +967,7 @@ func ExcerptBlob(ctx *context.Context) {
|
|||
}
|
||||
|
||||
func getExcerptLines(commit *git.Commit, filePath string, idxLeft, idxRight, chunkSize int) ([]*gitdiff.DiffLine, error) {
|
||||
blob, err := commit.Tree.GetBlobByPath(filePath)
|
||||
blob, err := commit.GetBlobByPath(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ func TestCleanUploadName(t *testing.T) {
|
|||
"..a.dotty../.folder../.name...": "..a.dotty../.folder../.name...",
|
||||
}
|
||||
for k, v := range kases {
|
||||
assert.EqualValues(t, cleanUploadFileName(k), v)
|
||||
assert.Equal(t, cleanUploadFileName(k), v)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,6 @@ func TestContainsParentDirectorySeparator(t *testing.T) {
|
|||
}
|
||||
|
||||
for i := range tests {
|
||||
assert.EqualValues(t, tests[i].b, containsParentDirectorySeparator(tests[i].v))
|
||||
assert.Equal(t, tests[i].b, containsParentDirectorySeparator(tests[i].v))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,9 +187,10 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
|
|||
// 0 means issues with no label
|
||||
// blank means labels will not be filtered for issues
|
||||
selectLabels := ctx.FormString("labels")
|
||||
if selectLabels == "" {
|
||||
switch selectLabels {
|
||||
case "":
|
||||
ctx.Data["AllLabels"] = true
|
||||
} else if selectLabels == "0" {
|
||||
case "0":
|
||||
ctx.Data["NoLabel"] = true
|
||||
}
|
||||
if len(selectLabels) > 0 {
|
||||
|
@ -426,9 +427,10 @@ func issues(ctx *context.Context, milestoneID, projectID int64, isPullOption opt
|
|||
return 0
|
||||
}
|
||||
reviewTyp := issues_model.ReviewTypeApprove
|
||||
if typ == "reject" {
|
||||
switch typ {
|
||||
case "reject":
|
||||
reviewTyp = issues_model.ReviewTypeReject
|
||||
} else if typ == "waiting" {
|
||||
case "waiting":
|
||||
reviewTyp = issues_model.ReviewTypeRequest
|
||||
}
|
||||
for _, count := range counts {
|
||||
|
@ -2128,7 +2130,7 @@ func checkBlockedByIssues(ctx *context.Context, blockers []*issues_model.Depende
|
|||
}
|
||||
repoPerms[blocker.RepoID] = perm
|
||||
}
|
||||
if perm.CanReadIssuesOrPulls(blocker.Issue.IsPull) {
|
||||
if perm.CanReadIssuesOrPulls(blocker.IsPull) {
|
||||
canRead = append(canRead, blocker)
|
||||
} else {
|
||||
notPermitted = append(notPermitted, blocker)
|
||||
|
@ -3117,7 +3119,7 @@ func NewComment(ctx *context.Context) {
|
|||
// Check if issue admin/poster changes the status of issue.
|
||||
if (ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) || (ctx.IsSigned && issue.IsPoster(ctx.Doer.ID))) &&
|
||||
(form.Status == "reopen" || form.Status == "close") &&
|
||||
!(issue.IsPull && issue.PullRequest.HasMerged) {
|
||||
(!issue.IsPull || !issue.PullRequest.HasMerged) {
|
||||
// Duplication and conflict check should apply to reopen pull request.
|
||||
var pr *issues_model.PullRequest
|
||||
|
||||
|
@ -3632,7 +3634,7 @@ func GetCommentAttachments(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if !ctx.Repo.Permission.CanReadIssuesOrPulls(comment.Issue.IsPull) {
|
||||
if !ctx.Repo.CanReadIssuesOrPulls(comment.Issue.IsPull) {
|
||||
ctx.NotFound("CanReadIssuesOrPulls", issues_model.ErrCommentNotExist{})
|
||||
return
|
||||
}
|
||||
|
|
|
@ -160,15 +160,16 @@ func GetContentHistoryDetail(ctx *context.Context) {
|
|||
diffHTMLBuf := bytes.Buffer{}
|
||||
diffHTMLBuf.WriteString("<pre class='chroma'>")
|
||||
for _, it := range diff {
|
||||
if it.Type == diffmatchpatch.DiffInsert {
|
||||
switch it.Type {
|
||||
case diffmatchpatch.DiffInsert:
|
||||
diffHTMLBuf.WriteString("<span class='gi'>")
|
||||
diffHTMLBuf.WriteString(html.EscapeString(it.Text))
|
||||
diffHTMLBuf.WriteString("</span>")
|
||||
} else if it.Type == diffmatchpatch.DiffDelete {
|
||||
case diffmatchpatch.DiffDelete:
|
||||
diffHTMLBuf.WriteString("<span class='gd'>")
|
||||
diffHTMLBuf.WriteString(html.EscapeString(it.Text))
|
||||
diffHTMLBuf.WriteString("</span>")
|
||||
} else {
|
||||
default:
|
||||
diffHTMLBuf.WriteString(html.EscapeString(it.Text))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ func TestInitializeLabels(t *testing.T) {
|
|||
contexttest.LoadRepo(t, ctx, 2)
|
||||
web.SetForm(ctx, &forms.InitializeLabelsForm{TemplateName: "Default"})
|
||||
InitializeLabels(ctx)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
unittest.AssertExistsAndLoadBean(t, &issues_model.Label{
|
||||
RepoID: 2,
|
||||
Name: "enhancement",
|
||||
|
@ -69,7 +69,7 @@ func TestRetrieveLabels(t *testing.T) {
|
|||
assert.True(t, ok)
|
||||
if assert.Len(t, labels, len(testCase.ExpectedLabelIDs)) {
|
||||
for i, label := range labels {
|
||||
assert.EqualValues(t, testCase.ExpectedLabelIDs[i], label.ID)
|
||||
assert.Equal(t, testCase.ExpectedLabelIDs[i], label.ID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ func TestNewLabel(t *testing.T) {
|
|||
Color: "#abcdef",
|
||||
})
|
||||
NewLabel(ctx)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
unittest.AssertExistsAndLoadBean(t, &issues_model.Label{
|
||||
Name: "newlabel",
|
||||
Color: "#abcdef",
|
||||
|
@ -105,7 +105,7 @@ func TestUpdateLabel(t *testing.T) {
|
|||
IsArchived: true,
|
||||
})
|
||||
UpdateLabel(ctx)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
unittest.AssertExistsAndLoadBean(t, &issues_model.Label{
|
||||
ID: 2,
|
||||
Name: "newnameforlabel",
|
||||
|
@ -121,7 +121,7 @@ func TestDeleteLabel(t *testing.T) {
|
|||
contexttest.LoadRepo(t, ctx, 1)
|
||||
ctx.Req.Form.Set("id", "2")
|
||||
DeleteLabel(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
unittest.AssertNotExistsBean(t, &issues_model.Label{ID: 2})
|
||||
unittest.AssertNotExistsBean(t, &issues_model.IssueLabel{LabelID: 2})
|
||||
assert.EqualValues(t, ctx.Tr("repo.issues.label_deletion_success"), ctx.Flash.SuccessMsg)
|
||||
|
@ -135,7 +135,7 @@ func TestUpdateIssueLabel_Clear(t *testing.T) {
|
|||
ctx.Req.Form.Set("issue_ids", "1,3")
|
||||
ctx.Req.Form.Set("action", "clear")
|
||||
UpdateIssueLabel(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
unittest.AssertNotExistsBean(t, &issues_model.IssueLabel{IssueID: 1})
|
||||
unittest.AssertNotExistsBean(t, &issues_model.IssueLabel{IssueID: 3})
|
||||
unittest.CheckConsistencyFor(t, &issues_model.Label{})
|
||||
|
@ -161,7 +161,7 @@ func TestUpdateIssueLabel_Toggle(t *testing.T) {
|
|||
ctx.Req.Form.Set("action", testCase.Action)
|
||||
ctx.Req.Form.Set("id", strconv.Itoa(int(testCase.LabelID)))
|
||||
UpdateIssueLabel(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
for _, issueID := range testCase.IssueIDs {
|
||||
unittest.AssertExistsIf(t, testCase.ExpectedAdd, &issues_model.IssueLabel{
|
||||
IssueID: issueID,
|
||||
|
|
|
@ -120,7 +120,7 @@ func Projects(ctx *context.Context) {
|
|||
pager.AddParam(ctx, "state", "State")
|
||||
ctx.Data["Page"] = pager
|
||||
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.CanWrite(unit.TypeProjects)
|
||||
ctx.Data["IsShowClosed"] = isShowClosed
|
||||
ctx.Data["IsProjectsPage"] = true
|
||||
ctx.Data["SortType"] = sortType
|
||||
|
@ -146,7 +146,7 @@ func RenderNewProject(ctx *context.Context) {
|
|||
ctx.Data["Title"] = ctx.Tr("repo.projects.new")
|
||||
ctx.Data["TemplateConfigs"] = project_model.GetTemplateConfigs()
|
||||
ctx.Data["CardTypes"] = project_model.GetCardConfig()
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.CanWrite(unit.TypeProjects)
|
||||
ctx.Data["CancelLink"] = ctx.Repo.Repository.Link() + "/projects"
|
||||
ctx.HTML(http.StatusOK, tplProjectsNew)
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ func DeleteProject(ctx *context.Context) {
|
|||
func RenderEditProject(ctx *context.Context) {
|
||||
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
|
||||
ctx.Data["PageIsEditProjects"] = true
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.CanWrite(unit.TypeProjects)
|
||||
ctx.Data["CardTypes"] = project_model.GetCardConfig()
|
||||
|
||||
p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
|
||||
|
@ -262,7 +262,7 @@ func EditProjectPost(ctx *context.Context) {
|
|||
|
||||
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
|
||||
ctx.Data["PageIsEditProjects"] = true
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.CanWrite(unit.TypeProjects)
|
||||
ctx.Data["CardTypes"] = project_model.GetCardConfig()
|
||||
ctx.Data["CancelLink"] = project_model.ProjectLinkForRepo(ctx.Repo.Repository, projectID)
|
||||
|
||||
|
@ -378,7 +378,7 @@ func ViewProject(ctx *context.Context) {
|
|||
|
||||
ctx.Data["Title"] = project.Title
|
||||
ctx.Data["IsProjectsPage"] = true
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
|
||||
ctx.Data["CanWriteProjects"] = ctx.Repo.CanWrite(unit.TypeProjects)
|
||||
ctx.Data["Project"] = project
|
||||
ctx.Data["IssuesMap"] = issuesMap
|
||||
ctx.Data["Columns"] = columns
|
||||
|
|
|
@ -892,7 +892,7 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
|
|||
foundStartCommit := len(specifiedStartCommit) == 0
|
||||
foundEndCommit := len(specifiedEndCommit) == 0
|
||||
|
||||
if !(foundStartCommit && foundEndCommit) {
|
||||
if !foundStartCommit || !foundEndCommit {
|
||||
for _, commit := range prInfo.Commits {
|
||||
if commit.ID.String() == specifiedStartCommit {
|
||||
foundStartCommit = true
|
||||
|
@ -907,7 +907,7 @@ func viewPullFiles(ctx *context.Context, specifiedStartCommit, specifiedEndCommi
|
|||
}
|
||||
}
|
||||
|
||||
if !(foundStartCommit && foundEndCommit) {
|
||||
if !foundStartCommit || !foundEndCommit {
|
||||
ctx.NotFound("Given SHA1 not found for this PR", nil)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -211,9 +211,10 @@ func renderConversation(ctx *context.Context, comment *issues_model.Comment, ori
|
|||
return
|
||||
}
|
||||
ctx.Data["AfterCommitID"] = pullHeadCommitID
|
||||
if origin == "diff" {
|
||||
switch origin {
|
||||
case "diff":
|
||||
ctx.HTML(http.StatusOK, tplDiffConversation)
|
||||
} else if origin == "timeline" {
|
||||
case "timeline":
|
||||
ctx.HTML(http.StatusOK, tplTimelineConversation)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func UpdateAvatarSetting(ctx *context.Context, form forms.AvatarForm) error {
|
|||
return fmt.Errorf("io.ReadAll: %w", err)
|
||||
}
|
||||
st := typesniffer.DetectContentType(data)
|
||||
if !(st.IsImage() && !st.IsSvgImage()) {
|
||||
if !st.IsImage() || st.IsSvgImage() {
|
||||
return errors.New(ctx.Locale.TrString("settings.uploaded_avatar_not_a_image"))
|
||||
}
|
||||
if err = repo_service.UploadAvatar(ctx, ctxRepo, data); err != nil {
|
||||
|
|
|
@ -55,7 +55,7 @@ func TestAddReadOnlyDeployKey(t *testing.T) {
|
|||
}
|
||||
web.SetForm(ctx, &addKeyForm)
|
||||
DeployKeysPost(ctx)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
|
||||
unittest.AssertExistsAndLoadBean(t, &asymkey_model.DeployKey{
|
||||
Name: addKeyForm.Title,
|
||||
|
@ -85,7 +85,7 @@ func TestAddReadWriteOnlyDeployKey(t *testing.T) {
|
|||
}
|
||||
web.SetForm(ctx, &addKeyForm)
|
||||
DeployKeysPost(ctx)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
|
||||
unittest.AssertExistsAndLoadBean(t, &asymkey_model.DeployKey{
|
||||
Name: addKeyForm.Title,
|
||||
|
@ -124,7 +124,7 @@ func TestCollaborationPost(t *testing.T) {
|
|||
|
||||
CollaborationPost(ctx)
|
||||
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
|
||||
exists, err := repo_model.IsCollaborator(ctx, re.ID, 4)
|
||||
require.NoError(t, err)
|
||||
|
@ -150,7 +150,7 @@ func TestCollaborationPost_InactiveUser(t *testing.T) {
|
|||
|
||||
CollaborationPost(ctx)
|
||||
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
|
||||
|
@ -184,7 +184,7 @@ func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
|
|||
|
||||
CollaborationPost(ctx)
|
||||
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
|
||||
exists, err := repo_model.IsCollaborator(ctx, re.ID, 4)
|
||||
require.NoError(t, err)
|
||||
|
@ -193,7 +193,7 @@ func TestCollaborationPost_AddCollaboratorTwice(t *testing.T) {
|
|||
// Try adding the same collaborator again
|
||||
CollaborationPost(ctx)
|
||||
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,7 @@ func TestCollaborationPost_NonExistentUser(t *testing.T) {
|
|||
|
||||
CollaborationPost(ctx)
|
||||
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
|
||||
|
@ -255,7 +255,7 @@ func TestAddTeamPost(t *testing.T) {
|
|||
AddTeamPost(ctx)
|
||||
|
||||
assert.True(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Empty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ func TestAddTeamPost_NotAllowed(t *testing.T) {
|
|||
AddTeamPost(ctx)
|
||||
|
||||
assert.False(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ func TestAddTeamPost_AddTeamTwice(t *testing.T) {
|
|||
|
||||
AddTeamPost(ctx)
|
||||
assert.True(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
|
||||
|
@ -369,7 +369,7 @@ func TestAddTeamPost_NonExistentTeam(t *testing.T) {
|
|||
ctx.Repo = repo
|
||||
|
||||
AddTeamPost(ctx)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ func assertPagesMetas(t *testing.T, expectedNames []string, metas any) {
|
|||
return
|
||||
}
|
||||
for i, pageMeta := range pageMetas {
|
||||
assert.EqualValues(t, expectedNames[i], pageMeta.Name)
|
||||
assert.Equal(t, expectedNames[i], pageMeta.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ func TestWiki(t *testing.T) {
|
|||
ctx.SetParams("*", "Home")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
Wiki(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.EqualValues(t, "Home", ctx.Data["Title"])
|
||||
assertPagesMetas(t, []string{"Home", "Long Page", "Page With Image", "Page With Spaced Name", "Unescaped File", "XSS"}, ctx.Data["Pages"])
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ func TestWikiPages(t *testing.T) {
|
|||
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_pages")
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
WikiPages(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
assertPagesMetas(t, []string{"Home", "Long Page", "Page With Image", "Page With Spaced Name", "Unescaped File", "XSS"}, ctx.Data["Pages"])
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ func TestNewWiki(t *testing.T) {
|
|||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
NewWiki(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.EqualValues(t, ctx.Tr("repo.wiki.new_page"), ctx.Data["Title"])
|
||||
}
|
||||
|
||||
|
@ -126,7 +126,7 @@ func TestNewWikiPost(t *testing.T) {
|
|||
Message: message,
|
||||
})
|
||||
NewWikiPost(ctx)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assertWikiExists(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title))
|
||||
assert.Equal(t, content, wikiContent(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title)))
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ func TestNewWikiPost_ReservedName(t *testing.T) {
|
|||
Message: message,
|
||||
})
|
||||
NewWikiPost(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.EqualValues(t, ctx.Tr("repo.wiki.reserved_page"), ctx.Flash.ErrorMsg)
|
||||
assertWikiNotExists(t, ctx.Repo.Repository, "_edit")
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ func TestEditWiki(t *testing.T) {
|
|||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
EditWiki(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.EqualValues(t, "Home", ctx.Data["Title"])
|
||||
assert.Equal(t, wikiContent(t, ctx.Repo.Repository, "Home"), ctx.Data["content"])
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ func TestEditWikiPost(t *testing.T) {
|
|||
Message: message,
|
||||
})
|
||||
EditWikiPost(ctx)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assertWikiExists(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title))
|
||||
assert.Equal(t, content, wikiContent(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title)))
|
||||
if title != "Home" {
|
||||
|
@ -194,7 +194,7 @@ func TestDeleteWikiPagePost(t *testing.T) {
|
|||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadRepo(t, ctx, 1)
|
||||
DeleteWikiPagePost(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
assertWikiNotExists(t, ctx.Repo.Repository, "Home")
|
||||
}
|
||||
|
||||
|
@ -215,10 +215,10 @@ func TestWikiRaw(t *testing.T) {
|
|||
contexttest.LoadRepo(t, ctx, 1)
|
||||
WikiRaw(ctx)
|
||||
if filetype == "" {
|
||||
assert.EqualValues(t, http.StatusNotFound, ctx.Resp.Status(), "filepath: %s", filepath)
|
||||
assert.Equal(t, http.StatusNotFound, ctx.Resp.Status(), "filepath: %s", filepath)
|
||||
} else {
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status(), "filepath: %s", filepath)
|
||||
assert.EqualValues(t, filetype, ctx.Resp.Header().Get("Content-Type"), "filepath: %s", filepath)
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status(), "filepath: %s", filepath)
|
||||
assert.Equal(t, filetype, ctx.Resp.Header().Get("Content-Type"), "filepath: %s", filepath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -655,9 +655,10 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
|
|||
return 0
|
||||
}
|
||||
reviewTyp := issues_model.ReviewTypeApprove
|
||||
if typ == "reject" {
|
||||
switch typ {
|
||||
case "reject":
|
||||
reviewTyp = issues_model.ReviewTypeReject
|
||||
} else if typ == "waiting" {
|
||||
case "waiting":
|
||||
reviewTyp = issues_model.ReviewTypeRequest
|
||||
}
|
||||
for _, count := range counts {
|
||||
|
|
|
@ -40,15 +40,15 @@ func TestArchivedIssues(t *testing.T) {
|
|||
NumIssues[repo.ID] = repo.NumIssues
|
||||
}
|
||||
assert.False(t, IsArchived[50])
|
||||
assert.EqualValues(t, 1, NumIssues[50])
|
||||
assert.Equal(t, 1, NumIssues[50])
|
||||
assert.True(t, IsArchived[51])
|
||||
assert.EqualValues(t, 1, NumIssues[51])
|
||||
assert.Equal(t, 1, NumIssues[51])
|
||||
|
||||
// Act
|
||||
Issues(ctx)
|
||||
|
||||
// Assert: One Issue (ID 30) from one Repo (ID 50) is retrieved, while nothing from archived Repo 51 is retrieved
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
|
||||
assert.Len(t, ctx.Data["Issues"], 1)
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func TestIssues(t *testing.T) {
|
|||
contexttest.LoadUser(t, ctx, 2)
|
||||
ctx.Req.Form.Set("state", "closed")
|
||||
Issues(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
|
||||
assert.EqualValues(t, true, ctx.Data["IsShowClosed"])
|
||||
assert.Len(t, ctx.Data["Issues"], 1)
|
||||
|
@ -76,7 +76,7 @@ func TestPulls(t *testing.T) {
|
|||
ctx.Req.Form.Set("state", "open")
|
||||
ctx.Req.Form.Set("type", "your_repositories")
|
||||
Pulls(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
|
||||
assert.Len(t, ctx.Data["Issues"], 5)
|
||||
}
|
||||
|
@ -91,15 +91,15 @@ func TestMilestones(t *testing.T) {
|
|||
ctx.Req.Form.Set("state", "closed")
|
||||
ctx.Req.Form.Set("sort", "furthestduedate")
|
||||
Milestones(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.EqualValues(t, map[int64]int64{1: 1}, ctx.Data["Counts"])
|
||||
assert.EqualValues(t, true, ctx.Data["IsShowClosed"])
|
||||
assert.EqualValues(t, "furthestduedate", ctx.Data["SortType"])
|
||||
assert.EqualValues(t, 1, ctx.Data["Total"])
|
||||
assert.Len(t, ctx.Data["Milestones"], 1)
|
||||
assert.Len(t, ctx.Data["Repos"], 2) // both repo 42 and 1 have milestones and both are owned by user 2
|
||||
assert.EqualValues(t, "user2/glob", ctx.Data["Repos"].(repo_model.RepositoryList)[0].FullName())
|
||||
assert.EqualValues(t, "user2/repo1", ctx.Data["Repos"].(repo_model.RepositoryList)[1].FullName())
|
||||
assert.Equal(t, "user2/glob", ctx.Data["Repos"].(repo_model.RepositoryList)[0].FullName())
|
||||
assert.Equal(t, "user2/repo1", ctx.Data["Repos"].(repo_model.RepositoryList)[1].FullName())
|
||||
}
|
||||
|
||||
func TestMilestonesForSpecificRepo(t *testing.T) {
|
||||
|
@ -113,7 +113,7 @@ func TestMilestonesForSpecificRepo(t *testing.T) {
|
|||
ctx.Req.Form.Set("state", "closed")
|
||||
ctx.Req.Form.Set("sort", "furthestduedate")
|
||||
Milestones(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.EqualValues(t, map[int64]int64{1: 1}, ctx.Data["Counts"])
|
||||
assert.EqualValues(t, true, ctx.Data["IsShowClosed"])
|
||||
assert.EqualValues(t, "furthestduedate", ctx.Data["SortType"])
|
||||
|
@ -144,7 +144,7 @@ func TestOrgLabels(t *testing.T) {
|
|||
contexttest.LoadUser(t, ctx, 2)
|
||||
contexttest.LoadOrganization(t, ctx, 3)
|
||||
Issues(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
|
||||
assert.True(t, ctx.Data["PageIsOrgIssues"].(bool))
|
||||
|
||||
|
@ -163,9 +163,9 @@ func TestOrgLabels(t *testing.T) {
|
|||
|
||||
if assert.Len(t, labels, len(orgLabels)) {
|
||||
for i, label := range labels {
|
||||
assert.EqualValues(t, orgLabels[i].OrgID, label.OrgID)
|
||||
assert.EqualValues(t, orgLabels[i].ID, label.ID)
|
||||
assert.EqualValues(t, orgLabels[i].Name, label.Name)
|
||||
assert.Equal(t, orgLabels[i].OrgID, label.OrgID)
|
||||
assert.Equal(t, orgLabels[i].ID, label.ID)
|
||||
assert.Equal(t, orgLabels[i].Name, label.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -340,9 +340,10 @@ func NotificationSubscriptions(ctx *context.Context) {
|
|||
return 0
|
||||
}
|
||||
reviewTyp := issues_model.ReviewTypeApprove
|
||||
if typ == "reject" {
|
||||
switch typ {
|
||||
case "reject":
|
||||
reviewTyp = issues_model.ReviewTypeReject
|
||||
} else if typ == "waiting" {
|
||||
case "waiting":
|
||||
reviewTyp = issues_model.ReviewTypeRequest
|
||||
}
|
||||
for _, count := range counts {
|
||||
|
|
|
@ -178,10 +178,10 @@ func EmailPost(ctx *context.Context) {
|
|||
// Set Email Notification Preference
|
||||
if ctx.FormString("_method") == "NOTIFICATION" {
|
||||
preference := ctx.FormString("preference")
|
||||
if !(preference == user_model.EmailNotificationsEnabled ||
|
||||
preference == user_model.EmailNotificationsOnMention ||
|
||||
preference == user_model.EmailNotificationsDisabled ||
|
||||
preference == user_model.EmailNotificationsAndYourOwn) {
|
||||
if preference != user_model.EmailNotificationsEnabled &&
|
||||
preference != user_model.EmailNotificationsOnMention &&
|
||||
preference != user_model.EmailNotificationsDisabled &&
|
||||
preference != user_model.EmailNotificationsAndYourOwn {
|
||||
log.Error("Email notifications preference change returned unrecognized option %s: %s", preference, ctx.Doer.Name)
|
||||
ctx.ServerError("SetEmailPreference", errors.New("option unrecognized"))
|
||||
return
|
||||
|
|
|
@ -95,7 +95,7 @@ func TestChangePassword(t *testing.T) {
|
|||
AccountPost(ctx)
|
||||
|
||||
assert.Contains(t, ctx.Flash.ErrorMsg, req.Message)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser *
|
|||
}
|
||||
|
||||
st := typesniffer.DetectContentType(data)
|
||||
if !(st.IsImage() && !st.IsSvgImage()) {
|
||||
if !st.IsImage() || st.IsSvgImage() {
|
||||
return errors.New(ctx.Locale.TrString("settings.uploaded_avatar_not_a_image"))
|
||||
}
|
||||
if err = user_service.UploadAvatar(ctx, ctxUser, data); err != nil {
|
||||
|
|
|
@ -812,13 +812,13 @@ func registerRoutes(m *web.Route) {
|
|||
individualPermsChecker := func(ctx *context.Context) {
|
||||
// org permissions have been checked in context.OrgAssignment(), but individual permissions haven't been checked.
|
||||
if ctx.ContextUser.IsIndividual() {
|
||||
switch {
|
||||
case ctx.ContextUser.Visibility == structs.VisibleTypePrivate:
|
||||
switch ctx.ContextUser.Visibility {
|
||||
case structs.VisibleTypePrivate:
|
||||
if ctx.Doer == nil || (ctx.ContextUser.ID != ctx.Doer.ID && !ctx.Doer.IsAdmin) {
|
||||
ctx.NotFound("Visit Project", nil)
|
||||
return
|
||||
}
|
||||
case ctx.ContextUser.Visibility == structs.VisibleTypeLimited:
|
||||
case structs.VisibleTypeLimited:
|
||||
if ctx.Doer == nil {
|
||||
ctx.NotFound("Visit Project", nil)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue