mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-10 14:58:09 +02:00
chore: update golangci-lint to v2.13.0
Migrate the deprecated gofumpt `extra-rules` to `extra.group-params`, as the alias now also enables the new `clothe-returns` and `balance-calls` rules. Disable SA4023, which hangs on go 1.27, see https://github.com/golangci/golangci-lint/issues/6732. Apply the resulting modernize fixes, mostly flattening embedded struct literals and switching errors.As to errors.AsType. Assisted-by: Claude:Opus 5
This commit is contained in:
@@ -35,8 +35,8 @@ func TestAddDeletedBranch(t *testing.T) {
|
||||
assert.True(t, secondBranch.IsDeleted)
|
||||
|
||||
commit := &git.Commit{
|
||||
ID: git.MustIDFromString(secondBranch.CommitID),
|
||||
CommitMessage: git.CommitMessage{MessageRaw: secondBranch.CommitMessage},
|
||||
ID: git.MustIDFromString(secondBranch.CommitID),
|
||||
MessageRaw: secondBranch.CommitMessage,
|
||||
Committer: &git.Signature{
|
||||
When: secondBranch.CommitTime.AsLocalTime(),
|
||||
},
|
||||
|
||||
@@ -28,9 +28,9 @@ func TestGetCommitStatuses(t *testing.T) {
|
||||
sha1 := "1234123412341234123412341234123412341234" // the mocked commit ID in test fixtures
|
||||
|
||||
statuses, maxResults, err := db.FindAndCount[git_model.CommitStatus](t.Context(), &git_model.CommitStatusOptions{
|
||||
ListOptions: db.ListOptions{Page: 1, PageSize: 50},
|
||||
RepoID: repo1.ID,
|
||||
SHA: sha1,
|
||||
Page: 1, PageSize: 50,
|
||||
RepoID: repo1.ID,
|
||||
SHA: sha1,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 5, int(maxResults))
|
||||
@@ -57,9 +57,9 @@ func TestGetCommitStatuses(t *testing.T) {
|
||||
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[4].APIURL(t.Context()))
|
||||
|
||||
statuses, maxResults, err = db.FindAndCount[git_model.CommitStatus](t.Context(), &git_model.CommitStatusOptions{
|
||||
ListOptions: db.ListOptions{Page: 2, PageSize: 50},
|
||||
RepoID: repo1.ID,
|
||||
SHA: sha1,
|
||||
Page: 2, PageSize: 50,
|
||||
RepoID: repo1.ID,
|
||||
SHA: sha1,
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, 5, int(maxResults))
|
||||
|
||||
+5
-5
@@ -149,12 +149,12 @@ func RemoveLFSMetaObjectByOidFn(ctx context.Context, repoID int64, oid string, f
|
||||
}
|
||||
|
||||
return db.WithTx2(ctx, func(ctx context.Context) (int64, error) {
|
||||
m := &LFSMetaObject{Pointer: lfs.Pointer{Oid: oid}, RepositoryID: repoID}
|
||||
m := &LFSMetaObject{Oid: oid, RepositoryID: repoID}
|
||||
if _, err := db.DeleteByBean(ctx, m); err != nil {
|
||||
return -1, err
|
||||
}
|
||||
|
||||
count, err := db.CountByBean(ctx, &LFSMetaObject{Pointer: lfs.Pointer{Oid: oid}})
|
||||
count, err := db.CountByBean(ctx, &LFSMetaObject{Oid: oid})
|
||||
if err != nil {
|
||||
return count, err
|
||||
}
|
||||
@@ -192,20 +192,20 @@ func CountLFSMetaObjects(ctx context.Context, repoID int64) (int64, error) {
|
||||
// LFSObjectAccessible checks if a provided Oid is accessible to the user
|
||||
func LFSObjectAccessible(ctx context.Context, user *user_model.User, oid string) (bool, error) {
|
||||
if user.IsAdmin {
|
||||
count, err := db.GetEngine(ctx).Count(&LFSMetaObject{Pointer: lfs.Pointer{Oid: oid}})
|
||||
count, err := db.GetEngine(ctx).Count(&LFSMetaObject{Oid: oid})
|
||||
return count > 0, err
|
||||
}
|
||||
// LFS objects are repository code content, so authorization must require
|
||||
// Code-unit access; other unit accesses (e.g. Issues) must not authorize
|
||||
// reuse of an existing LFS object across repositories.
|
||||
cond := repo_model.AccessibleRepositoryCondition(user, unit.TypeCode)
|
||||
count, err := db.GetEngine(ctx).Where(cond).Join("INNER", "repository", "`lfs_meta_object`.repository_id = `repository`.id").Count(&LFSMetaObject{Pointer: lfs.Pointer{Oid: oid}})
|
||||
count, err := db.GetEngine(ctx).Where(cond).Join("INNER", "repository", "`lfs_meta_object`.repository_id = `repository`.id").Count(&LFSMetaObject{Oid: oid})
|
||||
return count > 0, err
|
||||
}
|
||||
|
||||
// ExistsLFSObject checks if a provided Oid exists within the DB
|
||||
func ExistsLFSObject(ctx context.Context, oid string) (bool, error) {
|
||||
return db.GetEngine(ctx).Exist(&LFSMetaObject{Pointer: lfs.Pointer{Oid: oid}})
|
||||
return db.GetEngine(ctx).Exist(&LFSMetaObject{Oid: oid})
|
||||
}
|
||||
|
||||
// LFSAutoAssociate auto associates accessible LFSMetaObjects
|
||||
|
||||
@@ -57,10 +57,8 @@ func FindAllMatchedBranches(ctx context.Context, repoID int64, ruleName string)
|
||||
results := make([]string, 0, 10)
|
||||
for page := 1; ; page++ {
|
||||
brancheNames, err := FindBranchNames(ctx, FindBranchOptions{
|
||||
ListOptions: db.ListOptions{
|
||||
PageSize: 100,
|
||||
Page: page,
|
||||
},
|
||||
PageSize: 100,
|
||||
Page: page,
|
||||
RepoID: repoID,
|
||||
IsDeletedBranch: optional.Some(false),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user