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
|
@ -166,8 +166,8 @@ func (r artifactV4Routes) buildSignature(endp, expires, artifactName string, tas
|
|||
mac.Write([]byte(endp))
|
||||
mac.Write([]byte(expires))
|
||||
mac.Write([]byte(artifactName))
|
||||
mac.Write([]byte(fmt.Sprint(taskID)))
|
||||
mac.Write([]byte(fmt.Sprint(artifactID)))
|
||||
fmt.Fprint(mac, taskID)
|
||||
fmt.Fprint(mac, artifactID)
|
||||
return mac.Sum(nil)
|
||||
}
|
||||
|
||||
|
|
|
@ -48,13 +48,14 @@ func reqPackageAccess(accessMode perm.AccessMode) func(ctx *context.Context) {
|
|||
if ok { // it's a personal access token but not oauth2 token
|
||||
scopeMatched := false
|
||||
var err error
|
||||
if accessMode == perm.AccessModeRead {
|
||||
switch accessMode {
|
||||
case perm.AccessModeRead:
|
||||
scopeMatched, err = scope.HasScope(auth_model.AccessTokenScopeReadPackage)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "HasScope", err.Error())
|
||||
return
|
||||
}
|
||||
} else if accessMode == perm.AccessModeWrite {
|
||||
case perm.AccessModeWrite:
|
||||
scopeMatched, err = scope.HasScope(auth_model.AccessTokenScopeWritePackage)
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "HasScope", err.Error())
|
||||
|
|
|
@ -147,7 +147,7 @@ func getSignVersion(req *http.Request) (string, error) {
|
|||
version := m[1]
|
||||
|
||||
m = algorithmPattern.FindStringSubmatch(hdr)
|
||||
if len(m) == 2 && m[1] != "sha1" && !(m[1] == "sha256" && version == "1.3") {
|
||||
if len(m) == 2 && m[1] != "sha1" && (m[1] != "sha256" || version != "1.3") {
|
||||
return "", util.NewInvalidArgumentErrorf("unsupported algorithm")
|
||||
}
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ func EnumeratePackages(ctx *context.Context) {
|
|||
})
|
||||
}
|
||||
|
||||
skip, _ := opts.Paginator.GetSkipTake()
|
||||
skip, _ := opts.GetSkipTake()
|
||||
|
||||
ctx.JSON(http.StatusOK, &Result{
|
||||
Start: skip,
|
||||
|
|
|
@ -25,7 +25,7 @@ func (a *Auth) Name() string {
|
|||
func (a *Auth) Verify(req *http.Request, w http.ResponseWriter, store auth.DataStore, sess auth.SessionStore) (*user_model.User, error) {
|
||||
token, err := auth_model.GetAccessTokenBySHA(req.Context(), req.Header.Get("X-NuGet-ApiKey"))
|
||||
if err != nil {
|
||||
if !(auth_model.IsErrAccessTokenNotExist(err) || auth_model.IsErrAccessTokenEmpty(err)) {
|
||||
if !auth_model.IsErrAccessTokenNotExist(err) && !auth_model.IsErrAccessTokenEmpty(err) {
|
||||
log.Error("GetAccessTokenBySHA: %v", err)
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -203,19 +203,19 @@ func repoAssignment() func(ctx *context.APIContext) {
|
|||
}
|
||||
|
||||
if task.IsForkPullRequest {
|
||||
ctx.Repo.Permission.AccessMode = perm.AccessModeRead
|
||||
ctx.Repo.AccessMode = perm.AccessModeRead
|
||||
} else {
|
||||
ctx.Repo.Permission.AccessMode = perm.AccessModeWrite
|
||||
ctx.Repo.AccessMode = perm.AccessModeWrite
|
||||
}
|
||||
|
||||
if err := ctx.Repo.Repository.LoadUnits(ctx); err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "LoadUnits", err)
|
||||
return
|
||||
}
|
||||
ctx.Repo.Permission.Units = ctx.Repo.Repository.Units
|
||||
ctx.Repo.Permission.UnitsMode = make(map[unit.Type]perm.AccessMode)
|
||||
ctx.Repo.Units = ctx.Repo.Repository.Units
|
||||
ctx.Repo.UnitsMode = make(map[unit.Type]perm.AccessMode)
|
||||
for _, u := range ctx.Repo.Repository.Units {
|
||||
ctx.Repo.Permission.UnitsMode[u.Type] = ctx.Repo.Permission.AccessMode
|
||||
ctx.Repo.UnitsMode[u.Type] = ctx.Repo.AccessMode
|
||||
}
|
||||
} else {
|
||||
ctx.Repo.Permission, err = access_model.GetUserRepoPermission(ctx, repo, ctx.Doer)
|
||||
|
@ -692,7 +692,7 @@ func mustEnableIssues(ctx *context.APIContext) {
|
|||
}
|
||||
|
||||
func mustAllowPulls(ctx *context.APIContext) {
|
||||
if !(ctx.Repo.Repository.CanEnablePulls() && ctx.Repo.CanRead(unit.TypePullRequests)) {
|
||||
if !ctx.Repo.Repository.CanEnablePulls() || !ctx.Repo.CanRead(unit.TypePullRequests) {
|
||||
if ctx.Repo.Repository.CanEnablePulls() && log.IsTrace() {
|
||||
if ctx.IsSigned {
|
||||
log.Trace("Permission Denied: User %-v cannot read %-v in Repo %-v\n"+
|
||||
|
@ -716,7 +716,7 @@ func mustAllowPulls(ctx *context.APIContext) {
|
|||
|
||||
func mustEnableIssuesOrPulls(ctx *context.APIContext) {
|
||||
if !ctx.Repo.CanRead(unit.TypeIssues) &&
|
||||
!(ctx.Repo.Repository.CanEnablePulls() && ctx.Repo.CanRead(unit.TypePullRequests)) {
|
||||
(!ctx.Repo.Repository.CanEnablePulls() || !ctx.Repo.CanRead(unit.TypePullRequests)) {
|
||||
if ctx.Repo.Repository.CanEnablePulls() && log.IsTrace() {
|
||||
if ctx.IsSigned {
|
||||
log.Trace("Permission Denied: User %-v cannot read %-v and %-v in Repo %-v\n"+
|
||||
|
@ -777,13 +777,13 @@ func bind[T any](_ T) any {
|
|||
func individualPermsChecker(ctx *context.APIContext) {
|
||||
// org permissions have been checked in context.OrgAssignment(), but individual permissions haven't been checked.
|
||||
if ctx.ContextUser.IsIndividual() {
|
||||
switch {
|
||||
case ctx.ContextUser.Visibility == api.VisibleTypePrivate:
|
||||
switch ctx.ContextUser.Visibility {
|
||||
case api.VisibleTypePrivate:
|
||||
if ctx.Doer == nil || (ctx.ContextUser.ID != ctx.Doer.ID && !ctx.Doer.IsAdmin) {
|
||||
ctx.NotFound("Visit Project", nil)
|
||||
return
|
||||
}
|
||||
case ctx.ContextUser.Visibility == api.VisibleTypeLimited:
|
||||
case api.VisibleTypeLimited:
|
||||
if ctx.Doer == nil {
|
||||
ctx.NotFound("Visit Project", nil)
|
||||
return
|
||||
|
|
|
@ -231,9 +231,9 @@ func CreateBranch(ctx *context.APIContext) {
|
|||
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
|
||||
return
|
||||
}
|
||||
} else if len(opt.OldBranchName) > 0 { //nolint
|
||||
if ctx.Repo.GitRepo.IsBranchExist(opt.OldBranchName) { //nolint
|
||||
oldCommit, err = ctx.Repo.GitRepo.GetBranchCommit(opt.OldBranchName) //nolint
|
||||
} else if len(opt.OldBranchName) > 0 { //nolint:staticcheck
|
||||
if ctx.Repo.GitRepo.IsBranchExist(opt.OldBranchName) { //nolint:staticcheck
|
||||
oldCommit, err = ctx.Repo.GitRepo.GetBranchCommit(opt.OldBranchName) //nolint:staticcheck
|
||||
if err != nil {
|
||||
ctx.Error(http.StatusInternalServerError, "GetBranchCommit", err)
|
||||
return
|
||||
|
|
|
@ -437,7 +437,7 @@ func canWriteFiles(ctx *context.APIContext, branch string) bool {
|
|||
|
||||
// canReadFiles returns true if repository is readable and user has proper access level.
|
||||
func canReadFiles(r *context.Repository) bool {
|
||||
return r.Permission.CanRead(unit.TypeCode)
|
||||
return r.CanRead(unit.TypeCode)
|
||||
}
|
||||
|
||||
func base64Reader(s string) (io.ReadSeeker, error) {
|
||||
|
|
|
@ -25,7 +25,7 @@ func TestTestHook(t *testing.T) {
|
|||
defer ctx.Repo.GitRepo.Close()
|
||||
contexttest.LoadRepoCommit(t, ctx)
|
||||
TestHook(ctx)
|
||||
assert.EqualValues(t, http.StatusNoContent, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusNoContent, ctx.Resp.Status())
|
||||
|
||||
unittest.AssertExistsAndLoadBean(t, &webhook.HookTask{
|
||||
HookID: 1,
|
||||
|
|
|
@ -72,7 +72,7 @@ func GetIssueDependencies(ctx *context.APIContext) {
|
|||
}
|
||||
|
||||
// 1. We must be able to read this issue
|
||||
if !ctx.Repo.Permission.CanReadIssuesOrPulls(issue.IsPull) {
|
||||
if !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull) {
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ func GetIssueDependencies(ctx *context.APIContext) {
|
|||
limit = setting.API.MaxResponseItems
|
||||
}
|
||||
|
||||
canWrite := ctx.Repo.Permission.CanWriteIssuesOrPulls(issue.IsPull)
|
||||
canWrite := ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
|
||||
|
||||
blockerIssues := make([]*issues_model.Issue, 0, limit)
|
||||
|
||||
|
@ -123,7 +123,7 @@ func GetIssueDependencies(ctx *context.APIContext) {
|
|||
}
|
||||
|
||||
// check permission
|
||||
if !perm.CanReadIssuesOrPulls(blocker.Issue.IsPull) {
|
||||
if !perm.CanReadIssuesOrPulls(blocker.IsPull) {
|
||||
if !canWrite {
|
||||
hiddenBlocker := &issues_model.DependencyInfo{
|
||||
Issue: issues_model.Issue{
|
||||
|
@ -134,19 +134,19 @@ func GetIssueDependencies(ctx *context.APIContext) {
|
|||
} else {
|
||||
confidentialBlocker := &issues_model.DependencyInfo{
|
||||
Issue: issues_model.Issue{
|
||||
RepoID: blocker.Issue.RepoID,
|
||||
RepoID: blocker.RepoID,
|
||||
Index: blocker.Index,
|
||||
Title: blocker.Title,
|
||||
IsClosed: blocker.IsClosed,
|
||||
IsPull: blocker.IsPull,
|
||||
},
|
||||
Repository: repo_model.Repository{
|
||||
ID: blocker.Issue.Repo.ID,
|
||||
Name: blocker.Issue.Repo.Name,
|
||||
OwnerName: blocker.Issue.Repo.OwnerName,
|
||||
ID: blocker.Repo.ID,
|
||||
Name: blocker.Repo.Name,
|
||||
OwnerName: blocker.Repo.OwnerName,
|
||||
},
|
||||
}
|
||||
confidentialBlocker.Issue.Repo = &confidentialBlocker.Repository
|
||||
confidentialBlocker.Repo = &confidentialBlocker.Repository
|
||||
blocker = confidentialBlocker
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ func GetIssueBlocks(ctx *context.APIContext) {
|
|||
return
|
||||
}
|
||||
|
||||
if !ctx.Repo.Permission.CanReadIssuesOrPulls(issue.IsPull) {
|
||||
if !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull) {
|
||||
ctx.NotFound()
|
||||
return
|
||||
}
|
||||
|
@ -373,11 +373,11 @@ func GetIssueBlocks(ctx *context.APIContext) {
|
|||
repoPerms[depMeta.RepoID] = perm
|
||||
}
|
||||
|
||||
if !perm.CanReadIssuesOrPulls(depMeta.Issue.IsPull) {
|
||||
if !perm.CanReadIssuesOrPulls(depMeta.IsPull) {
|
||||
continue
|
||||
}
|
||||
|
||||
depMeta.Issue.Repo = &depMeta.Repository
|
||||
depMeta.Repo = &depMeta.Repository
|
||||
issues = append(issues, &depMeta.Issue)
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ func TestRepoEdit(t *testing.T) {
|
|||
web.SetForm(ctx, &opts)
|
||||
Edit(ctx)
|
||||
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{
|
||||
ID: 1,
|
||||
}, unittest.Cond("name = ? AND is_archived = 1", *opts.Name))
|
||||
|
@ -78,7 +78,7 @@ func TestRepoEditNameChange(t *testing.T) {
|
|||
|
||||
web.SetForm(ctx, &opts)
|
||||
Edit(ctx)
|
||||
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
|
||||
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
|
||||
|
||||
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{
|
||||
ID: 1,
|
||||
|
|
|
@ -24,9 +24,10 @@ import (
|
|||
|
||||
// appendPrivateInformation appends the owner and key type information to api.PublicKey
|
||||
func appendPrivateInformation(ctx std_ctx.Context, apiKey *api.PublicKey, key *asymkey_model.PublicKey, defaultUser *user_model.User) (*api.PublicKey, error) {
|
||||
if key.Type == asymkey_model.KeyTypeDeploy {
|
||||
switch key.Type {
|
||||
case asymkey_model.KeyTypeDeploy:
|
||||
apiKey.KeyType = "deploy"
|
||||
} else if key.Type == asymkey_model.KeyTypeUser {
|
||||
case asymkey_model.KeyTypeUser:
|
||||
apiKey.KeyType = "user"
|
||||
|
||||
if defaultUser.ID == key.OwnerID {
|
||||
|
@ -38,7 +39,7 @@ func appendPrivateInformation(ctx std_ctx.Context, apiKey *api.PublicKey, key *a
|
|||
}
|
||||
apiKey.Owner = convert.ToUser(ctx, user, user)
|
||||
}
|
||||
} else {
|
||||
default:
|
||||
apiKey.KeyType = "unknown"
|
||||
}
|
||||
apiKey.ReadOnly = key.Mode == perm.AccessModeRead
|
||||
|
|
|
@ -155,7 +155,7 @@ func ListMyRepos(ctx *context.APIContext) {
|
|||
results[i] = convert.ToRepo(ctx, repo, permission)
|
||||
}
|
||||
|
||||
ctx.SetLinkHeader(int(count), opts.ListOptions.PageSize)
|
||||
ctx.SetLinkHeader(int(count), opts.PageSize)
|
||||
ctx.SetTotalCountHeader(count)
|
||||
ctx.JSON(http.StatusOK, &results)
|
||||
}
|
||||
|
|
|
@ -19,18 +19,18 @@ func TestRoutes(t *testing.T) {
|
|||
w := httptest.NewRecorder()
|
||||
req := httptest.NewRequest("GET", "/", nil)
|
||||
r.ServeHTTP(w, req)
|
||||
assert.EqualValues(t, 200, w.Code)
|
||||
assert.Equal(t, 200, w.Code)
|
||||
assert.Contains(t, w.Body.String(), `class="page-content install"`)
|
||||
|
||||
w = httptest.NewRecorder()
|
||||
req = httptest.NewRequest("GET", "/no-such", nil)
|
||||
r.ServeHTTP(w, req)
|
||||
assert.EqualValues(t, 404, w.Code)
|
||||
assert.Equal(t, 404, w.Code)
|
||||
|
||||
w = httptest.NewRecorder()
|
||||
req = httptest.NewRequest("GET", "/assets/img/gitea.svg", nil)
|
||||
r.ServeHTTP(w, req)
|
||||
assert.EqualValues(t, 200, w.Code)
|
||||
assert.Equal(t, 200, w.Code)
|
||||
}
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
|
|
|
@ -44,7 +44,7 @@ func TestHandlePullRequestMerging(t *testing.T) {
|
|||
pr, err = issues_model.GetPullRequestByID(db.DefaultContext, pr.ID)
|
||||
require.NoError(t, err)
|
||||
assert.True(t, pr.HasMerged)
|
||||
assert.EqualValues(t, "01234567", pr.MergedCommitID)
|
||||
assert.Equal(t, "01234567", pr.MergedCommitID)
|
||||
|
||||
unittest.AssertNotExistsBean(t, &pull_model.AutoMerge{ID: autoMerge.ID})
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ func (ctx *preReceiveContext) checkQuota() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
ok, err := quota_model.EvaluateForUser(ctx, ctx.PrivateContext.Repo.Repository.OwnerID, quota_model.LimitSubjectSizeReposAll)
|
||||
ok, err := quota_model.EvaluateForUser(ctx, ctx.Repo.Repository.OwnerID, quota_model.LimitSubjectSizeReposAll)
|
||||
if err != nil {
|
||||
log.Error("quota_model.EvaluateForUser: %v", err)
|
||||
ctx.JSON(http.StatusInternalServerError, private.Response{
|
||||
|
@ -531,10 +531,7 @@ func preReceiveFor(ctx *preReceiveContext, oldCommitID, newCommitID string, refF
|
|||
|
||||
baseBranchName := refFullName.ForBranchName()
|
||||
|
||||
baseBranchExist := false
|
||||
if ctx.Repo.GitRepo.IsBranchExist(baseBranchName) {
|
||||
baseBranchExist = true
|
||||
}
|
||||
baseBranchExist := ctx.Repo.GitRepo.IsBranchExist(baseBranchName)
|
||||
|
||||
if !baseBranchExist {
|
||||
for p, v := range baseBranchName {
|
||||
|
|
|
@ -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