Skip to content

Commit 093a1a1

Browse files
authored
Merge branch 'main' into repotable
2 parents dc821e3 + 33e8e82 commit 093a1a1

File tree

142 files changed

+464
-467
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+464
-467
lines changed

.golangci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ linters:
1919
- revive
2020
- staticcheck
2121
- stylecheck
22+
- tenv
23+
- testifylint
2224
- typecheck
2325
- unconvert
2426
- unused
@@ -34,6 +36,10 @@ output:
3436
show-stats: true
3537

3638
linters-settings:
39+
testifylint:
40+
disable:
41+
- go-require
42+
- require-error
3743
stylecheck:
3844
checks: ["all", "-ST1005", "-ST1003"]
3945
nakedret:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ XGO_VERSION := go-1.23.x
2828
AIR_PACKAGE ?= github.com/air-verse/air@v1
2929
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/[email protected]
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
31-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.60.3
31+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]

models/actions/runner_token_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func TestGetLatestRunnerToken(t *testing.T) {
1717
token := unittest.AssertExistsAndLoadBean(t, &ActionRunnerToken{ID: 3})
1818
expectedToken, err := GetLatestRunnerToken(db.DefaultContext, 1, 0)
1919
assert.NoError(t, err)
20-
assert.EqualValues(t, token, expectedToken)
20+
assert.EqualValues(t, expectedToken, token)
2121
}
2222

2323
func TestNewRunnerToken(t *testing.T) {
@@ -26,7 +26,7 @@ func TestNewRunnerToken(t *testing.T) {
2626
assert.NoError(t, err)
2727
expectedToken, err := GetLatestRunnerToken(db.DefaultContext, 1, 0)
2828
assert.NoError(t, err)
29-
assert.EqualValues(t, token, expectedToken)
29+
assert.EqualValues(t, expectedToken, token)
3030
}
3131

3232
func TestUpdateRunnerToken(t *testing.T) {
@@ -36,5 +36,5 @@ func TestUpdateRunnerToken(t *testing.T) {
3636
assert.NoError(t, UpdateRunnerToken(db.DefaultContext, token))
3737
expectedToken, err := GetLatestRunnerToken(db.DefaultContext, 1, 0)
3838
assert.NoError(t, err)
39-
assert.EqualValues(t, token, expectedToken)
39+
assert.EqualValues(t, expectedToken, token)
4040
}

models/activities/user_heatmap_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package activities_test
55

66
import (
7-
"fmt"
87
"testing"
98
"time"
109

@@ -91,11 +90,11 @@ func TestGetUserHeatmapDataByUser(t *testing.T) {
9190
assert.NoError(t, err)
9291
assert.Len(t, actions, contributions, "invalid action count: did the test data became too old?")
9392
assert.Equal(t, count, int64(contributions))
94-
assert.Equal(t, tc.CountResult, contributions, fmt.Sprintf("testcase '%s'", tc.desc))
93+
assert.Equal(t, tc.CountResult, contributions, "testcase '%s'", tc.desc)
9594

9695
// Test JSON rendering
9796
jsonData, err := json.Marshal(heatmap)
9897
assert.NoError(t, err)
99-
assert.Equal(t, tc.JSONResult, string(jsonData))
98+
assert.JSONEq(t, tc.JSONResult, string(jsonData))
10099
}
101100
}

models/auth/oauth2_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestOAuth2Application_GenerateClientSecret(t *testing.T) {
1818
app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1})
1919
secret, err := app.GenerateClientSecret(db.DefaultContext)
2020
assert.NoError(t, err)
21-
assert.True(t, len(secret) > 0)
21+
assert.NotEmpty(t, secret)
2222
unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1, ClientSecret: app.ClientSecret})
2323
}
2424

@@ -165,7 +165,7 @@ func TestOAuth2Grant_GenerateNewAuthorizationCode(t *testing.T) {
165165
code, err := grant.GenerateNewAuthorizationCode(db.DefaultContext, "https://example2.com/callback", "CjvyTLSdR47G5zYenDA-eDWW4lRrO8yvjcWwbD_deOg", "S256")
166166
assert.NoError(t, err)
167167
assert.NotNil(t, code)
168-
assert.True(t, len(code.Code) > 32) // secret length > 32
168+
assert.Greater(t, len(code.Code), 32) // secret length > 32
169169
}
170170

171171
func TestOAuth2Grant_TableName(t *testing.T) {

models/db/iterate_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ func TestIterate(t *testing.T) {
3838
if !has {
3939
return db.ErrNotExist{Resource: "repo_unit", ID: repoUnit.ID}
4040
}
41-
assert.EqualValues(t, repoUnit.RepoID, repoUnit.RepoID)
42-
assert.EqualValues(t, repoUnit.CreatedUnix, repoUnit.CreatedUnix)
4341
return nil
4442
})
4543
assert.NoError(t, err)

models/git/commit_status_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestGetCommitStatuses(t *testing.T) {
3434
SHA: sha1,
3535
})
3636
assert.NoError(t, err)
37-
assert.Equal(t, int(maxResults), 5)
37+
assert.Equal(t, 5, int(maxResults))
3838
assert.Len(t, statuses, 5)
3939

4040
assert.Equal(t, "ci/awesomeness", statuses[0].Context)
@@ -63,7 +63,7 @@ func TestGetCommitStatuses(t *testing.T) {
6363
SHA: sha1,
6464
})
6565
assert.NoError(t, err)
66-
assert.Equal(t, int(maxResults), 5)
66+
assert.Equal(t, 5, int(maxResults))
6767
assert.Empty(t, statuses)
6868
}
6969

models/git/protected_branch_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
package git
55

66
import (
7-
"fmt"
87
"testing"
98

109
"code.gitea.io/gitea/models/db"
@@ -76,7 +75,7 @@ func TestBranchRuleMatch(t *testing.T) {
7675
infact = " not"
7776
}
7877
assert.EqualValues(t, kase.ExpectedMatch, pb.Match(kase.BranchName),
79-
fmt.Sprintf("%s should%s match %s but it is%s", kase.BranchName, should, kase.Rule, infact),
78+
"%s should%s match %s but it is%s", kase.BranchName, should, kase.Rule, infact,
8079
)
8180
}
8281
}

models/issues/comment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestFetchCodeComments(t *testing.T) {
6464
}
6565

6666
func TestAsCommentType(t *testing.T) {
67-
assert.Equal(t, issues_model.CommentType(0), issues_model.CommentTypeComment)
67+
assert.Equal(t, issues_model.CommentTypeComment, issues_model.CommentType(0))
6868
assert.Equal(t, issues_model.CommentTypeUndefined, issues_model.AsCommentType(""))
6969
assert.Equal(t, issues_model.CommentTypeUndefined, issues_model.AsCommentType("nonsense"))
7070
assert.Equal(t, issues_model.CommentTypeComment, issues_model.AsCommentType("comment"))

models/issues/issue_index.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ func RecalculateIssueIndexForRepo(ctx context.Context, repoID int64) error {
1818
}
1919
defer committer.Close()
2020

21-
var max int64
22-
if _, err = db.GetEngine(ctx).Select(" MAX(`index`)").Table("issue").Where("repo_id=?", repoID).Get(&max); err != nil {
21+
var maxIndex int64
22+
if _, err = db.GetEngine(ctx).Select(" MAX(`index`)").Table("issue").Where("repo_id=?", repoID).Get(&maxIndex); err != nil {
2323
return err
2424
}
2525

26-
if err = db.SyncMaxResourceIndex(ctx, "issue_index", repoID, max); err != nil {
26+
if err = db.SyncMaxResourceIndex(ctx, "issue_index", repoID, maxIndex); err != nil {
2727
return err
2828
}
2929

0 commit comments

Comments
 (0)