Update to go 1.26.0 and golangci-lint 2.9.0 (#36588)

This commit is contained in:
silverwind
2026-02-11 18:37:13 +01:00
committed by GitHub
parent 3754e9dd12
commit 45ee571693
30 changed files with 95 additions and 130 deletions
+3 -3
View File
@@ -54,12 +54,12 @@ func TestCodebaseDownloadRepo(t *testing.T) {
assertMilestonesEqual(t, []*base.Milestone{
{
Title: "Milestone1",
Deadline: timePtr(time.Date(2021, time.September, 16, 0, 0, 0, 0, time.UTC)),
Deadline: new(time.Date(2021, time.September, 16, 0, 0, 0, 0, time.UTC)),
},
{
Title: "Milestone2",
Deadline: timePtr(time.Date(2021, time.September, 17, 0, 0, 0, 0, time.UTC)),
Closed: timePtr(time.Date(2021, time.September, 17, 0, 0, 0, 0, time.UTC)),
Deadline: new(time.Date(2021, time.September, 17, 0, 0, 0, 0, time.UTC)),
Closed: new(time.Date(2021, time.September, 17, 0, 0, 0, 0, time.UTC)),
State: "closed",
},
}, milestones)
+4 -5
View File
@@ -14,7 +14,6 @@ import (
"code.gitea.io/gitea/modules/log"
base "code.gitea.io/gitea/modules/migration"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
"github.com/aws/aws-sdk-go-v2/credentials"
"github.com/aws/aws-sdk-go-v2/service/codecommit"
@@ -87,7 +86,7 @@ type CodeCommitDownloader struct {
// GetRepoInfo returns a repository information
func (c *CodeCommitDownloader) GetRepoInfo(ctx context.Context) (*base.Repository, error) {
output, err := c.codeCommitClient.GetRepository(ctx, &codecommit.GetRepositoryInput{
RepositoryName: util.ToPointer(c.repoName),
RepositoryName: new(c.repoName),
})
if err != nil {
return nil, err
@@ -119,7 +118,7 @@ func (c *CodeCommitDownloader) GetComments(ctx context.Context, commentable base
for {
resp, err := c.codeCommitClient.GetCommentsForPullRequest(ctx, &codecommit.GetCommentsForPullRequestInput{
NextToken: nextToken,
PullRequestId: util.ToPointer(strconv.FormatInt(commentable.GetForeignIndex(), 10)),
PullRequestId: new(strconv.FormatInt(commentable.GetForeignIndex(), 10)),
})
if err != nil {
return nil, false, err
@@ -161,7 +160,7 @@ func (c *CodeCommitDownloader) GetPullRequests(ctx context.Context, page, perPag
prs := make([]*base.PullRequest, 0, len(batch))
for _, id := range batch {
output, err := c.codeCommitClient.GetPullRequest(ctx, &codecommit.GetPullRequestInput{
PullRequestId: util.ToPointer(id),
PullRequestId: new(id),
})
if err != nil {
return nil, false, err
@@ -241,7 +240,7 @@ func (c *CodeCommitDownloader) getAllPullRequestIDs(ctx context.Context) ([]stri
for {
output, err := c.codeCommitClient.ListPullRequests(ctx, &codecommit.ListPullRequestsInput{
RepositoryName: util.ToPointer(c.repoName),
RepositoryName: new(c.repoName),
NextToken: nextToken,
})
if err != nil {
+8 -8
View File
@@ -86,16 +86,16 @@ func TestGiteaDownloadRepo(t *testing.T) {
{
Title: "V2 Finalize",
Created: time.Unix(0, 0),
Deadline: timePtr(time.Unix(1599263999, 0)),
Updated: timePtr(time.Unix(0, 0)),
Deadline: new(time.Unix(1599263999, 0)),
Updated: new(time.Unix(0, 0)),
State: "open",
},
{
Title: "V1",
Description: "Generate Content",
Created: time.Unix(0, 0),
Updated: timePtr(time.Unix(0, 0)),
Closed: timePtr(time.Unix(1598985406, 0)),
Updated: new(time.Unix(0, 0)),
Closed: new(time.Unix(1598985406, 0)),
State: "closed",
},
}, milestones)
@@ -171,7 +171,7 @@ func TestGiteaDownloadRepo(t *testing.T) {
Content: "laugh",
},
},
Closed: timePtr(time.Date(2020, 9, 1, 15, 49, 34, 0, time.UTC)),
Closed: new(time.Date(2020, 9, 1, 15, 49, 34, 0, time.UTC)),
},
{
Number: 2,
@@ -190,7 +190,7 @@ func TestGiteaDownloadRepo(t *testing.T) {
Color: "d4c5f9",
Description: "",
}},
Closed: timePtr(time.Unix(1598969497, 0)),
Closed: new(time.Unix(1598969497, 0)),
},
}, issues)
@@ -237,7 +237,7 @@ func TestGiteaDownloadRepo(t *testing.T) {
IsLocked: false,
Created: time.Unix(1598982759, 0),
Updated: time.Unix(1599023425, 0),
Closed: timePtr(time.Unix(1598982934, 0)),
Closed: new(time.Unix(1598982934, 0)),
Assignees: []string{"techknowlogick"},
Base: base.PullRequestBranch{
CloneURL: "",
@@ -254,7 +254,7 @@ func TestGiteaDownloadRepo(t *testing.T) {
OwnerName: "6543-forks",
},
Merged: true,
MergedTime: timePtr(time.Unix(1598982934, 0)),
MergedTime: new(time.Unix(1598982934, 0)),
MergeCommitSHA: "827aa28a907853e5ddfa40c8f9bc52471a2685fd",
PatchURL: "https://gitea.com/gitea/test_repo/pulls/12.patch",
}, prs[1])
+10 -10
View File
@@ -47,19 +47,19 @@ func TestGitHubDownloadRepo(t *testing.T) {
{
Title: "1.0.0",
Description: "Milestone 1.0.0",
Deadline: timePtr(time.Date(2019, 11, 11, 8, 0, 0, 0, time.UTC)),
Deadline: new(time.Date(2019, 11, 11, 8, 0, 0, 0, time.UTC)),
Created: time.Date(2019, 11, 12, 19, 37, 8, 0, time.UTC),
Updated: timePtr(time.Date(2019, 11, 12, 21, 56, 17, 0, time.UTC)),
Closed: timePtr(time.Date(2019, 11, 12, 19, 45, 49, 0, time.UTC)),
Updated: new(time.Date(2019, 11, 12, 21, 56, 17, 0, time.UTC)),
Closed: new(time.Date(2019, 11, 12, 19, 45, 49, 0, time.UTC)),
State: "closed",
},
{
Title: "1.1.0",
Description: "Milestone 1.1.0",
Deadline: timePtr(time.Date(2019, 11, 12, 8, 0, 0, 0, time.UTC)),
Deadline: new(time.Date(2019, 11, 12, 8, 0, 0, 0, time.UTC)),
Created: time.Date(2019, 11, 12, 19, 37, 25, 0, time.UTC),
Updated: timePtr(time.Date(2019, 11, 12, 21, 39, 27, 0, time.UTC)),
Closed: timePtr(time.Date(2019, 11, 12, 19, 45, 46, 0, time.UTC)),
Updated: new(time.Date(2019, 11, 12, 21, 39, 27, 0, time.UTC)),
Closed: new(time.Date(2019, 11, 12, 19, 45, 46, 0, time.UTC)),
State: "closed",
},
}, milestones)
@@ -163,7 +163,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
Content: "+1",
},
},
Closed: timePtr(time.Date(2019, 11, 12, 20, 22, 22, 0, time.UTC)),
Closed: new(time.Date(2019, 11, 12, 20, 22, 22, 0, time.UTC)),
},
{
Number: 2,
@@ -214,7 +214,7 @@ func TestGitHubDownloadRepo(t *testing.T) {
Content: "+1",
},
},
Closed: timePtr(time.Date(2019, 11, 12, 21, 1, 31, 0, time.UTC)),
Closed: new(time.Date(2019, 11, 12, 21, 1, 31, 0, time.UTC)),
},
}, issues)
@@ -284,9 +284,9 @@ func TestGitHubDownloadRepo(t *testing.T) {
OwnerName: "go-gitea",
RepoName: "test_repo",
},
Closed: timePtr(time.Date(2019, 11, 12, 21, 39, 27, 0, time.UTC)),
Closed: new(time.Date(2019, 11, 12, 21, 39, 27, 0, time.UTC)),
Merged: true,
MergedTime: timePtr(time.Date(2019, 11, 12, 21, 39, 27, 0, time.UTC)),
MergedTime: new(time.Date(2019, 11, 12, 21, 39, 27, 0, time.UTC)),
MergeCommitSHA: "f32b0a9dfd09a60f616f29158f772cedd89942d2",
ForeignIndex: 3,
},
+5 -5
View File
@@ -59,14 +59,14 @@ func TestGitlabDownloadRepo(t *testing.T) {
{
Title: "1.1.0",
Created: time.Date(2019, 11, 28, 8, 42, 44, 575000000, time.UTC),
Updated: timePtr(time.Date(2019, 11, 28, 8, 42, 44, 575000000, time.UTC)),
Updated: new(time.Date(2019, 11, 28, 8, 42, 44, 575000000, time.UTC)),
State: "active",
},
{
Title: "1.0.0",
Created: time.Date(2019, 11, 28, 8, 42, 30, 301000000, time.UTC),
Updated: timePtr(time.Date(2019, 11, 28, 15, 57, 52, 401000000, time.UTC)),
Closed: timePtr(time.Date(2019, 11, 28, 15, 57, 52, 401000000, time.UTC)),
Updated: new(time.Date(2019, 11, 28, 15, 57, 52, 401000000, time.UTC)),
Closed: new(time.Date(2019, 11, 28, 15, 57, 52, 401000000, time.UTC)),
State: "closed",
},
}, milestones)
@@ -161,7 +161,7 @@ func TestGitlabDownloadRepo(t *testing.T) {
Content: "open_mouth",
},
},
Closed: timePtr(time.Date(2019, 11, 28, 8, 46, 23, 275000000, time.UTC)),
Closed: new(time.Date(2019, 11, 28, 8, 46, 23, 275000000, time.UTC)),
},
{
Number: 2,
@@ -210,7 +210,7 @@ func TestGitlabDownloadRepo(t *testing.T) {
Content: "hearts",
},
},
Closed: timePtr(time.Date(2019, 11, 28, 8, 45, 44, 959000000, time.UTC)),
Closed: new(time.Date(2019, 11, 28, 8, 45, 44, 959000000, time.UTC)),
},
}, issues)
-4
View File
@@ -18,10 +18,6 @@ func TestMain(m *testing.M) {
unittest.MainTest(m)
}
func timePtr(t time.Time) *time.Time {
return &t
}
func assertTimeEqual(t *testing.T, expected, actual time.Time) {
assert.Equal(t, expected.UTC(), actual.UTC())
}
+5 -5
View File
@@ -173,18 +173,18 @@ func getFileContentsByEntryInternal(ctx context.Context, repo *repo_model.Reposi
}
if opts.IncludeCommitMetadata {
contentsResponse.LastCommitSHA = util.ToPointer(lastCommit.ID.String())
contentsResponse.LastCommitSHA = new(lastCommit.ID.String())
// GitHub doesn't have these fields in the response, but we could follow other similar APIs to name them
// https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits
if lastCommit.Committer != nil {
contentsResponse.LastCommitterDate = util.ToPointer(lastCommit.Committer.When)
contentsResponse.LastCommitterDate = new(lastCommit.Committer.When)
}
if lastCommit.Author != nil {
contentsResponse.LastAuthorDate = util.ToPointer(lastCommit.Author.When)
contentsResponse.LastAuthorDate = new(lastCommit.Author.When)
}
}
if opts.IncludeCommitMessage {
contentsResponse.LastCommitMessage = util.ToPointer(lastCommit.Message())
contentsResponse.LastCommitMessage = new(lastCommit.Message())
}
}
@@ -281,7 +281,7 @@ func GetBlobBySHA(repo *repo_model.Repository, gitRepo *git.Repository, sha stri
return nil, err
}
ret.Encoding, ret.Content = util.ToPointer("base64"), &content
ret.Encoding, ret.Content = new("base64"), &content
if originContent != nil {
ret.LfsOid, ret.LfsSize = parsePossibleLfsPointerBuffer(strings.NewReader(originContent.String()))
}
+2 -3
View File
@@ -8,7 +8,6 @@ import (
"code.gitea.io/gitea/models/unittest"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/services/contexttest"
_ "code.gitea.io/gitea/models/actions"
@@ -37,8 +36,8 @@ func TestGetContents(t *testing.T) {
ctx.SetPathParam("sha", sha)
gbr, err := GetBlobBySHA(ctx.Repo.Repository, ctx.Repo.GitRepo, ctx.PathParam("sha"))
expectedGBR := &api.GitBlobResponse{
Content: util.ToPointer("dHJlZSAyYTJmMWQ0NjcwNzI4YTJlMTAwNDllMzQ1YmQ3YTI3NjQ2OGJlYWI2CmF1dGhvciB1c2VyMSA8YWRkcmVzczFAZXhhbXBsZS5jb20+IDE0ODk5NTY0NzkgLTA0MDAKY29tbWl0dGVyIEV0aGFuIEtvZW5pZyA8ZXRoYW50a29lbmlnQGdtYWlsLmNvbT4gMTQ4OTk1NjQ3OSAtMDQwMAoKSW5pdGlhbCBjb21taXQK"),
Encoding: util.ToPointer("base64"),
Content: new("dHJlZSAyYTJmMWQ0NjcwNzI4YTJlMTAwNDllMzQ1YmQ3YTI3NjQ2OGJlYWI2CmF1dGhvciB1c2VyMSA8YWRkcmVzczFAZXhhbXBsZS5jb20+IDE0ODk5NTY0NzkgLTA0MDAKY29tbWl0dGVyIEV0aGFuIEtvZW5pZyA8ZXRoYW50a29lbmlnQGdtYWlsLmNvbT4gMTQ4OTk1NjQ3OSAtMDQwMAoKSW5pdGlhbCBjb21taXQK"),
Encoding: new("base64"),
URL: "https://try.gitea.io/api/v1/repos/user2/repo1/git/blobs/65f1bf27bc3bf70f64657658635e66094edbcb4d",
SHA: "65f1bf27bc3bf70f64657658635e66094edbcb4d",
Size: 180,
+1 -1
View File
@@ -259,7 +259,7 @@ func (t *TemporaryUploadRepository) CommitTree(ctx context.Context, opts *Commit
authorDate := opts.AuthorTime
committerDate := opts.CommitterTime
if authorDate == nil && committerDate == nil {
authorDate = util.ToPointer(time.Now())
authorDate = new(time.Now())
committerDate = authorDate
} else if authorDate == nil {
authorDate = committerDate