From 45ee571693818014966735afc87592ba5df63dfa Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 11 Feb 2026 18:37:13 +0100 Subject: [PATCH] Update to go 1.26.0 and golangci-lint 2.9.0 (#36588) --- Dockerfile | 2 +- Dockerfile.rootless | 2 +- Makefile | 2 +- go.mod | 4 +-- models/asymkey/gpg_key_test.go | 5 ++-- modules/util/util.go | 5 ---- modules/util/util_test.go | 9 ------- modules/web/router_test.go | 8 +++--- routers/web/repo/attachment.go | 3 +-- services/migrations/codebase_test.go | 6 ++--- services/migrations/codecommit.go | 9 +++---- services/migrations/gitea_downloader_test.go | 16 ++++++------ services/migrations/github_test.go | 20 +++++++-------- services/migrations/gitlab_test.go | 10 ++++---- services/migrations/main_test.go | 4 --- services/repository/files/content.go | 10 ++++---- services/repository/files/content_test.go | 5 ++-- services/repository/files/temp_repo.go | 2 +- tests/integration/actions_approve_test.go | 3 +-- tests/integration/actions_concurrency_test.go | 3 +-- tests/integration/actions_schedule_test.go | 15 ++++++----- tests/integration/actions_trigger_test.go | 3 +-- tests/integration/api_pull_test.go | 2 +- .../integration/api_repo_file_create_test.go | 11 ++++---- .../integration/api_repo_file_update_test.go | 7 +++--- .../api_repo_get_contents_list_test.go | 7 +++--- .../integration/api_repo_get_contents_test.go | 21 ++++++++-------- tests/integration/pull_create_test.go | 3 +-- tests/integration/repo_merge_upstream_test.go | 3 +-- tests/integration/repofiles_change_test.go | 25 +++++++++---------- 30 files changed, 95 insertions(+), 130 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7893db73e8..79f507dbc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 # Build stage -FROM docker.io/library/golang:1.25-alpine3.23 AS build-env +FROM docker.io/library/golang:1.26-alpine3.23 AS build-env ARG GOPROXY=direct diff --git a/Dockerfile.rootless b/Dockerfile.rootless index 6640c2b2de..fe94774add 100644 --- a/Dockerfile.rootless +++ b/Dockerfile.rootless @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 # Build stage -FROM docker.io/library/golang:1.25-alpine3.23 AS build-env +FROM docker.io/library/golang:1.26-alpine3.23 AS build-env ARG GOPROXY=direct diff --git a/Makefile b/Makefile index 6054611580..93d87fc139 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ XGO_VERSION := go-1.25.x AIR_PACKAGE ?= github.com/air-verse/air@v1 EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3 GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.9.2 -GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.8.0 +GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.9.0 GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.15 MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.7.0 SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1 diff --git a/go.mod b/go.mod index 0d47b731ea..f784ac2581 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module code.gitea.io/gitea -go 1.25.0 - -toolchain go1.25.7 +go 1.26.0 // rfc5280 said: "The serial number is an integer assigned by the CA to each certificate." // But some CAs use negative serial number, just relax the check. related: diff --git a/models/asymkey/gpg_key_test.go b/models/asymkey/gpg_key_test.go index 4621337f11..e6656cb70d 100644 --- a/models/asymkey/gpg_key_test.go +++ b/models/asymkey/gpg_key_test.go @@ -11,7 +11,6 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/timeutil" - "code.gitea.io/gitea/modules/util" "github.com/ProtonMail/go-crypto/openpgp" "github.com/ProtonMail/go-crypto/openpgp/packet" @@ -398,7 +397,7 @@ epiDVQ== func TestTryGetKeyIDFromSignature(t *testing.T) { assert.Empty(t, TryGetKeyIDFromSignature(&packet.Signature{})) assert.Equal(t, "038D1A3EADDBEA9C", TryGetKeyIDFromSignature(&packet.Signature{ - IssuerKeyId: util.ToPointer(uint64(0x38D1A3EADDBEA9C)), + IssuerKeyId: new(uint64(0x38D1A3EADDBEA9C)), })) assert.Equal(t, "038D1A3EADDBEA9C", TryGetKeyIDFromSignature(&packet.Signature{ IssuerFingerprint: []uint8{0xb, 0x23, 0x24, 0xc7, 0xe6, 0xfe, 0x4f, 0x3a, 0x6, 0x26, 0xc1, 0x21, 0x3, 0x8d, 0x1a, 0x3e, 0xad, 0xdb, 0xea, 0x9c}, @@ -419,7 +418,7 @@ func TestParseGPGKey(t *testing.T) { // then revoke the key for _, id := range e.Identities { - id.Revocations = append(id.Revocations, &packet.Signature{RevocationReason: util.ToPointer(packet.KeyCompromised)}) + id.Revocations = append(id.Revocations, &packet.Signature{RevocationReason: new(packet.KeyCompromised)}) } k, err = parseGPGKey(t.Context(), 1, e, true) require.NoError(t, err) diff --git a/modules/util/util.go b/modules/util/util.go index dd8e073888..f197d4d6a4 100644 --- a/modules/util/util.go +++ b/modules/util/util.go @@ -197,11 +197,6 @@ func ToFloat64(number any) (float64, error) { return value, nil } -// ToPointer returns the pointer of a copy of any given value -func ToPointer[T any](val T) *T { - return &val -} - // Iif is an "inline-if", it returns "trueVal" if "condition" is true, otherwise "falseVal" func Iif[T any](condition bool, trueVal, falseVal T) T { if condition { diff --git a/modules/util/util_test.go b/modules/util/util_test.go index fe4125cdb5..38876276e3 100644 --- a/modules/util/util_test.go +++ b/modules/util/util_test.go @@ -212,15 +212,6 @@ func TestToTitleCase(t *testing.T) { assert.Equal(t, `Foo Bar Baz`, ToTitleCase(`FOO BAR BAZ`)) } -func TestToPointer(t *testing.T) { - assert.Equal(t, "abc", *ToPointer("abc")) - assert.Equal(t, 123, *ToPointer(123)) - abc := "abc" - assert.NotSame(t, &abc, ToPointer(abc)) - val123 := 123 - assert.NotSame(t, &val123, ToPointer(val123)) -} - func TestReserveLineBreakForTextarea(t *testing.T) { assert.Equal(t, "test\ndata", ReserveLineBreakForTextarea("test\r\ndata")) assert.Equal(t, "test\ndata\n", ReserveLineBreakForTextarea("test\r\ndata\r\n")) diff --git a/modules/web/router_test.go b/modules/web/router_test.go index f216aa6180..ab5fbb502c 100644 --- a/modules/web/router_test.go +++ b/modules/web/router_test.go @@ -69,7 +69,7 @@ func TestRouter(t *testing.T) { chiCtx := chi.RouteContext(req.Context()) res.method = req.Method res.pathParams = chiURLParamsToMap(chiCtx) - res.chiRoutePattern = util.ToPointer(chiCtx.RoutePattern()) + res.chiRoutePattern = new(chiCtx.RoutePattern()) if mark != "" { res.handlerMarks = append(res.handlerMarks, mark) } @@ -139,7 +139,7 @@ func TestRouter(t *testing.T) { testRoute(t, "GET /the-user/the-repo/other", resultStruct{ method: "GET", handlerMarks: []string{"not-found:/"}, - chiRoutePattern: util.ToPointer(""), + chiRoutePattern: new(""), }) testRoute(t, "GET /the-user/the-repo/pulls", resultStruct{ method: "GET", @@ -150,7 +150,7 @@ func TestRouter(t *testing.T) { method: "GET", pathParams: map[string]string{"username": "the-user", "reponame": "the-repo", "type": "issues", "index": "123"}, handlerMarks: []string{"view-issue"}, - chiRoutePattern: util.ToPointer("/{username}/{reponame}/{type:issues|pulls}/{index}"), + chiRoutePattern: new("/{username}/{reponame}/{type:issues|pulls}/{index}"), }) testRoute(t, "GET /the-user/the-repo/issues/123?stop=hijack", resultStruct{ method: "GET", @@ -228,7 +228,7 @@ func TestRouter(t *testing.T) { method: "GET", pathParams: map[string]string{"username": "the-user", "reponame": "the-repo", "*": "d1/d2/fn", "dir": "d1/d2", "file": "fn"}, handlerMarks: []string{"s1", "s2", "s3"}, - chiRoutePattern: util.ToPointer("/api/v1/repos/{username}/{reponame}/branches//"), + chiRoutePattern: new("/api/v1/repos/{username}/{reponame}/branches//"), }) }) } diff --git a/routers/web/repo/attachment.go b/routers/web/repo/attachment.go index ae52eb2ffa..bc14e42543 100644 --- a/routers/web/repo/attachment.go +++ b/routers/web/repo/attachment.go @@ -14,7 +14,6 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/storage" - "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/routers/common" "code.gitea.io/gitea/services/attachment" "code.gitea.io/gitea/services/context" @@ -200,7 +199,7 @@ func ServeAttachment(ctx *context.Context, uuid string) { } defer fr.Close() - common.ServeContentByReadSeeker(ctx.Base, attach.Name, util.ToPointer(attach.CreatedUnix.AsTime()), fr) + common.ServeContentByReadSeeker(ctx.Base, attach.Name, new(attach.CreatedUnix.AsTime()), fr) } // GetAttachment serve attachments diff --git a/services/migrations/codebase_test.go b/services/migrations/codebase_test.go index 6cd52e5e59..dabe7e1ac9 100644 --- a/services/migrations/codebase_test.go +++ b/services/migrations/codebase_test.go @@ -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) diff --git a/services/migrations/codecommit.go b/services/migrations/codecommit.go index d08b2e6d4a..188280273f 100644 --- a/services/migrations/codecommit.go +++ b/services/migrations/codecommit.go @@ -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 { diff --git a/services/migrations/gitea_downloader_test.go b/services/migrations/gitea_downloader_test.go index 1a9094f6f2..cf727b44c7 100644 --- a/services/migrations/gitea_downloader_test.go +++ b/services/migrations/gitea_downloader_test.go @@ -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]) diff --git a/services/migrations/github_test.go b/services/migrations/github_test.go index 6d1a5378b9..198062f7cf 100644 --- a/services/migrations/github_test.go +++ b/services/migrations/github_test.go @@ -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, }, diff --git a/services/migrations/gitlab_test.go b/services/migrations/gitlab_test.go index fef1053ec8..9e4050289d 100644 --- a/services/migrations/gitlab_test.go +++ b/services/migrations/gitlab_test.go @@ -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) diff --git a/services/migrations/main_test.go b/services/migrations/main_test.go index 581af614f9..9893b4e7d1 100644 --- a/services/migrations/main_test.go +++ b/services/migrations/main_test.go @@ -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()) } diff --git a/services/repository/files/content.go b/services/repository/files/content.go index d32d3041c2..fc0e00a1a7 100644 --- a/services/repository/files/content.go +++ b/services/repository/files/content.go @@ -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())) } diff --git a/services/repository/files/content_test.go b/services/repository/files/content_test.go index d72f918074..dda5572ad0 100644 --- a/services/repository/files/content_test.go +++ b/services/repository/files/content_test.go @@ -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, diff --git a/services/repository/files/temp_repo.go b/services/repository/files/temp_repo.go index a579b807ba..68d1df24b7 100644 --- a/services/repository/files/temp_repo.go +++ b/services/repository/files/temp_repo.go @@ -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 diff --git a/tests/integration/actions_approve_test.go b/tests/integration/actions_approve_test.go index f2d6f75f88..3f2c02f77a 100644 --- a/tests/integration/actions_approve_test.go +++ b/tests/integration/actions_approve_test.go @@ -17,7 +17,6 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" api "code.gitea.io/gitea/modules/structs" - "code.gitea.io/gitea/modules/util" "github.com/stretchr/testify/assert" ) @@ -68,7 +67,7 @@ jobs: // user4 forks the repo req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/forks", baseRepo.OwnerName, baseRepo.Name), &api.CreateForkOption{ - Name: util.ToPointer("approve-all-runs-fork"), + Name: new("approve-all-runs-fork"), }).AddTokenAuth(user4Token) resp := MakeRequest(t, req, http.StatusAccepted) var apiForkRepo api.Repository diff --git a/tests/integration/actions_concurrency_test.go b/tests/integration/actions_concurrency_test.go index 653376d554..b904230a95 100644 --- a/tests/integration/actions_concurrency_test.go +++ b/tests/integration/actions_concurrency_test.go @@ -19,7 +19,6 @@ import ( "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/timeutil" - "code.gitea.io/gitea/modules/util" webhook_module "code.gitea.io/gitea/modules/webhook" actions_service "code.gitea.io/gitea/services/actions" @@ -420,7 +419,7 @@ jobs: // user4 forks the repo req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/forks", baseRepo.OwnerName, baseRepo.Name), &api.CreateForkOption{ - Name: util.ToPointer("actions-concurrency-fork"), + Name: new("actions-concurrency-fork"), }).AddTokenAuth(user4Token) resp := MakeRequest(t, req, http.StatusAccepted) var apiForkRepo api.Repository diff --git a/tests/integration/actions_schedule_test.go b/tests/integration/actions_schedule_test.go index dda4f1421e..43c44ede55 100644 --- a/tests/integration/actions_schedule_test.go +++ b/tests/integration/actions_schedule_test.go @@ -19,7 +19,6 @@ import ( user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/modules/migration" api "code.gitea.io/gitea/modules/structs" - "code.gitea.io/gitea/modules/util" mirror_service "code.gitea.io/gitea/services/mirror" repo_service "code.gitea.io/gitea/services/repository" files_service "code.gitea.io/gitea/services/repository/files" @@ -103,8 +102,8 @@ jobs: doTestScheduleUpdate(t, func(t *testing.T, u *url.URL, testContext APITestContext, user *user_model.User, repo *repo_model.Repository) (commitID, expectedSpec string) { // enable manual-merge doAPIEditRepository(testContext, &api.EditRepoOption{ - HasPullRequests: util.ToPointer(true), - AllowManualMerge: util.ToPointer(true), + HasPullRequests: new(true), + AllowManualMerge: new(true), })(t) // update workflow file @@ -170,7 +169,7 @@ func testScheduleUpdateMirrorSync(t *testing.T) { // enable actions unit for mirror repo assert.False(t, mirrorRepo.UnitEnabled(t.Context(), unit_model.TypeActions)) doAPIEditRepository(mirrorContext, &api.EditRepoOption{ - HasActions: util.ToPointer(true), + HasActions: new(true), })(t) actionSchedule := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionSchedule{RepoID: mirrorRepo.ID}) scheduleSpec := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionScheduleSpec{RepoID: mirrorRepo.ID, ScheduleID: actionSchedule.ID}) @@ -201,11 +200,11 @@ func testScheduleUpdateMirrorSync(t *testing.T) { func testScheduleUpdateArchiveAndUnarchive(t *testing.T) { doTestScheduleUpdate(t, func(t *testing.T, u *url.URL, testContext APITestContext, user *user_model.User, repo *repo_model.Repository) (commitID, expectedSpec string) { doAPIEditRepository(testContext, &api.EditRepoOption{ - Archived: util.ToPointer(true), + Archived: new(true), })(t) assert.Zero(t, unittest.GetCount(t, &actions_model.ActionSchedule{RepoID: repo.ID})) doAPIEditRepository(testContext, &api.EditRepoOption{ - Archived: util.ToPointer(false), + Archived: new(false), })(t) branch, err := git_model.GetBranch(t.Context(), repo.ID, repo.DefaultBranch) assert.NoError(t, err) @@ -216,11 +215,11 @@ func testScheduleUpdateArchiveAndUnarchive(t *testing.T) { func testScheduleUpdateDisableAndEnableActionsUnit(t *testing.T) { doTestScheduleUpdate(t, func(t *testing.T, u *url.URL, testContext APITestContext, user *user_model.User, repo *repo_model.Repository) (commitID, expectedSpec string) { doAPIEditRepository(testContext, &api.EditRepoOption{ - HasActions: util.ToPointer(false), + HasActions: new(false), })(t) assert.Zero(t, unittest.GetCount(t, &actions_model.ActionSchedule{RepoID: repo.ID})) doAPIEditRepository(testContext, &api.EditRepoOption{ - HasActions: util.ToPointer(true), + HasActions: new(true), })(t) branch, err := git_model.GetBranch(t.Context(), repo.ID, repo.DefaultBranch) assert.NoError(t, err) diff --git a/tests/integration/actions_trigger_test.go b/tests/integration/actions_trigger_test.go index fd3f2a0294..b0eabdd432 100644 --- a/tests/integration/actions_trigger_test.go +++ b/tests/integration/actions_trigger_test.go @@ -29,7 +29,6 @@ import ( api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" "code.gitea.io/gitea/modules/timeutil" - "code.gitea.io/gitea/modules/util" webhook_module "code.gitea.io/gitea/modules/webhook" issue_service "code.gitea.io/gitea/services/issue" pull_service "code.gitea.io/gitea/services/pull" @@ -1406,7 +1405,7 @@ jobs: // user4 forks the repo req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/forks", baseRepo.OwnerName, baseRepo.Name), &api.CreateForkOption{ - Name: util.ToPointer("close-pull-request-with-path-fork"), + Name: new("close-pull-request-with-path-fork"), }).AddTokenAuth(user4Token) resp := MakeRequest(t, req, http.StatusAccepted) var apiForkRepo api.Repository diff --git a/tests/integration/api_pull_test.go b/tests/integration/api_pull_test.go index 0e1a88dcee..61a37ddd01 100644 --- a/tests/integration/api_pull_test.go +++ b/tests/integration/api_pull_test.go @@ -304,7 +304,7 @@ func TestAPICreatePullBasePermission(t *testing.T) { Base: "master", Title: prTitle, - AllowMaintainerEdit: util.ToPointer(true), + AllowMaintainerEdit: new(true), } req := NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls", owner10.Name, repo10.Name), &opts).AddTokenAuth(token) MakeRequest(t, req, http.StatusForbidden) diff --git a/tests/integration/api_repo_file_create_test.go b/tests/integration/api_repo_file_create_test.go index 7cf1083248..5bc920a274 100644 --- a/tests/integration/api_repo_file_create_test.go +++ b/tests/integration/api_repo_file_create_test.go @@ -19,7 +19,6 @@ import ( "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" - "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/context" "github.com/stretchr/testify/assert" @@ -53,8 +52,8 @@ func getCreateFileOptions() api.CreateFileOptions { func normalizeFileContentResponseCommitTime(c *api.ContentsResponse) { // decoded JSON response may contain different timezone from the one parsed by git commit // so we need to normalize the time to UTC to make "assert.Equal" pass - c.LastCommitterDate = util.ToPointer(c.LastCommitterDate.UTC()) - c.LastAuthorDate = util.ToPointer(c.LastAuthorDate.UTC()) + c.LastCommitterDate = new(c.LastCommitterDate.UTC()) + c.LastAuthorDate = new(c.LastAuthorDate.UTC()) } type apiFileResponseInfo struct { @@ -75,9 +74,9 @@ func getExpectedFileResponseForCreate(info apiFileResponseInfo) *api.FileRespons Name: path.Base(info.treePath), Path: info.treePath, SHA: sha, - LastCommitSHA: util.ToPointer(info.lastCommitSHA), - LastCommitterDate: util.ToPointer(info.lastCommitterWhen), - LastAuthorDate: util.ToPointer(info.lastAuthorWhen), + LastCommitSHA: new(info.lastCommitSHA), + LastCommitterDate: new(info.lastCommitterWhen), + LastAuthorDate: new(info.lastAuthorWhen), Size: 16, Type: "file", Encoding: &encoding, diff --git a/tests/integration/api_repo_file_update_test.go b/tests/integration/api_repo_file_update_test.go index 6e6aae389f..2847e01791 100644 --- a/tests/integration/api_repo_file_update_test.go +++ b/tests/integration/api_repo_file_update_test.go @@ -18,7 +18,6 @@ import ( "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" - "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/context" "github.com/stretchr/testify/assert" @@ -59,9 +58,9 @@ func getExpectedFileResponseForUpdate(info apiFileResponseInfo) *api.FileRespons Name: path.Base(info.treePath), Path: info.treePath, SHA: sha, - LastCommitSHA: util.ToPointer(info.lastCommitSHA), - LastCommitterDate: util.ToPointer(info.lastCommitterWhen), - LastAuthorDate: util.ToPointer(info.lastAuthorWhen), + LastCommitSHA: new(info.lastCommitSHA), + LastCommitterDate: new(info.lastCommitterWhen), + LastAuthorDate: new(info.lastAuthorWhen), Type: "file", Size: 20, Encoding: &encoding, diff --git a/tests/integration/api_repo_get_contents_list_test.go b/tests/integration/api_repo_get_contents_list_test.go index 4984559f0c..679ad37bef 100644 --- a/tests/integration/api_repo_get_contents_list_test.go +++ b/tests/integration/api_repo_get_contents_list_test.go @@ -17,7 +17,6 @@ import ( "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" - "code.gitea.io/gitea/modules/util" repo_service "code.gitea.io/gitea/services/repository" "github.com/stretchr/testify/assert" @@ -35,9 +34,9 @@ func getExpectedContentsListResponseForContents(ref, refType, lastCommitSHA stri Name: path.Base(treePath), Path: treePath, SHA: sha, - LastCommitSHA: util.ToPointer(lastCommitSHA), - LastCommitterDate: util.ToPointer(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))), - LastAuthorDate: util.ToPointer(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))), + LastCommitSHA: new(lastCommitSHA), + LastCommitterDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))), + LastAuthorDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))), Type: "file", Size: 30, URL: &selfURL, diff --git a/tests/integration/api_repo_get_contents_test.go b/tests/integration/api_repo_get_contents_test.go index 6225c96bc6..33960b1ea3 100644 --- a/tests/integration/api_repo_get_contents_test.go +++ b/tests/integration/api_repo_get_contents_test.go @@ -18,7 +18,6 @@ import ( "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" - "code.gitea.io/gitea/modules/util" repo_service "code.gitea.io/gitea/services/repository" "github.com/stretchr/testify/assert" @@ -34,17 +33,17 @@ func getExpectedContentsResponseForContents(ref, refType, lastCommitSHA string) Name: treePath, Path: treePath, SHA: "4b4851ad51df6a7d9f25c979345979eaeb5b349f", - LastCommitSHA: util.ToPointer(lastCommitSHA), - LastCommitterDate: util.ToPointer(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))), - LastAuthorDate: util.ToPointer(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))), + LastCommitSHA: new(lastCommitSHA), + LastCommitterDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))), + LastAuthorDate: new(time.Date(2017, time.March, 19, 16, 47, 59, 0, time.FixedZone("", -14400))), Type: "file", Size: 30, - Encoding: util.ToPointer("base64"), - Content: util.ToPointer("IyByZXBvMQoKRGVzY3JpcHRpb24gZm9yIHJlcG8x"), + Encoding: new("base64"), + Content: new("IyByZXBvMQoKRGVzY3JpcHRpb24gZm9yIHJlcG8x"), URL: &selfURL, HTMLURL: &htmlURL, GitURL: &gitURL, - DownloadURL: util.ToPointer(setting.AppURL + "user2/repo1/raw/" + refType + "/" + ref + "/" + treePath), + DownloadURL: new(setting.AppURL + "user2/repo1/raw/" + refType + "/" + ref + "/" + treePath), Links: &api.FileLinksResponse{ Self: &selfURL, GitURL: &gitURL, @@ -256,8 +255,8 @@ func testAPIGetContentsExt(t *testing.T) { assert.Equal(t, "jpeg.jpg", respFile.Name) assert.Nil(t, respFile.Encoding) assert.Nil(t, respFile.Content) - assert.Equal(t, util.ToPointer(int64(107)), respFile.LfsSize) - assert.Equal(t, util.ToPointer("0b8d8b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351"), respFile.LfsOid) + assert.Equal(t, new(int64(107)), respFile.LfsSize) + assert.Equal(t, new("0b8d8b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351"), respFile.LfsOid) }) t.Run("FileContents", func(t *testing.T) { // by default, no file content or commit info is returned @@ -296,7 +295,7 @@ func testAPIGetContentsExt(t *testing.T) { assert.NotNil(t, respFile.Content) assert.Nil(t, contentsResponse.FileContents.LastCommitSHA) assert.Nil(t, contentsResponse.FileContents.LastCommitMessage) - assert.Equal(t, util.ToPointer(int64(107)), respFile.LfsSize) - assert.Equal(t, util.ToPointer("0b8d8b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351"), respFile.LfsOid) + assert.Equal(t, new(int64(107)), respFile.LfsSize) + assert.Equal(t, new("0b8d8b5f15046343fd32f451df93acc2bdd9e6373be478b968e4cad6b6647351"), respFile.LfsOid) }) } diff --git a/tests/integration/pull_create_test.go b/tests/integration/pull_create_test.go index 518f452e28..3db335fc3f 100644 --- a/tests/integration/pull_create_test.go +++ b/tests/integration/pull_create_test.go @@ -20,7 +20,6 @@ import ( "code.gitea.io/gitea/modules/git/gitcmd" api "code.gitea.io/gitea/modules/structs" "code.gitea.io/gitea/modules/test" - "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/tests" "github.com/stretchr/testify/assert" @@ -330,7 +329,7 @@ func TestCreatePullRequestFromNestedOrgForks(t *testing.T) { forkIntoOrg := func(srcOrg, dstOrg string) api.Repository { req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/forks", srcOrg, repoName), &api.CreateForkOption{ - Organization: util.ToPointer(dstOrg), + Organization: new(dstOrg), }).AddTokenAuth(token) resp := MakeRequest(t, req, http.StatusAccepted) var forkRepo api.Repository diff --git a/tests/integration/repo_merge_upstream_test.go b/tests/integration/repo_merge_upstream_test.go index 84c87066cb..fcc6078fcd 100644 --- a/tests/integration/repo_merge_upstream_test.go +++ b/tests/integration/repo_merge_upstream_test.go @@ -18,7 +18,6 @@ import ( "code.gitea.io/gitea/models/unittest" user_model "code.gitea.io/gitea/models/user" api "code.gitea.io/gitea/modules/structs" - "code.gitea.io/gitea/modules/util" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -42,7 +41,7 @@ func TestRepoMergeUpstream(t *testing.T) { // create a fork req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/forks", baseUser.Name, baseRepo.Name), &api.CreateForkOption{ - Name: util.ToPointer("test-repo-fork"), + Name: new("test-repo-fork"), }).AddTokenAuth(token) MakeRequest(t, req, http.StatusAccepted) forkRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: forkUser.ID, Name: "test-repo-fork"}) diff --git a/tests/integration/repofiles_change_test.go b/tests/integration/repofiles_change_test.go index 6fd42401c5..442959b8a5 100644 --- a/tests/integration/repofiles_change_test.go +++ b/tests/integration/repofiles_change_test.go @@ -17,7 +17,6 @@ import ( "code.gitea.io/gitea/modules/gitrepo" "code.gitea.io/gitea/modules/setting" api "code.gitea.io/gitea/modules/structs" - "code.gitea.io/gitea/modules/util" "code.gitea.io/gitea/services/contexttest" files_service "code.gitea.io/gitea/services/repository/files" @@ -107,9 +106,9 @@ func getExpectedFileResponseForRepoFilesCreate(commitID string, lastCommit *git. Name: path.Base(treePath), Path: treePath, SHA: "103ff9234cefeee5ec5361d22b49fbb04d385885", - LastCommitSHA: util.ToPointer(lastCommit.ID.String()), - LastCommitterDate: util.ToPointer(lastCommit.Committer.When), - LastAuthorDate: util.ToPointer(lastCommit.Author.When), + LastCommitSHA: new(lastCommit.ID.String()), + LastCommitterDate: new(lastCommit.Committer.When), + LastAuthorDate: new(lastCommit.Author.When), Type: "file", Size: 18, Encoding: &encoding, @@ -177,9 +176,9 @@ func getExpectedFileResponseForRepoFilesUpdate(commitID, filename, lastCommitSHA Name: filename, Path: filename, SHA: "dbf8d00e022e05b7e5cf7e535de857de57925647", - LastCommitSHA: util.ToPointer(lastCommitSHA), - LastCommitterDate: util.ToPointer(lastCommitterWhen), - LastAuthorDate: util.ToPointer(lastAuthorWhen), + LastCommitSHA: new(lastCommitSHA), + LastCommitterDate: new(lastCommitterWhen), + LastAuthorDate: new(lastAuthorWhen), Type: "file", Size: 43, Encoding: &encoding, @@ -253,8 +252,8 @@ func getExpectedFileResponseForRepoFilesUpdateRename(commitID, lastCommitSHA str sha: "d4a41a0d4db4949e129bd22f871171ea988103ef", size: 129, content: "dmVyc2lvbiBodHRwczovL2dpdC1sZnMuZ2l0aHViLmNvbS9zcGVjL3YxCm9pZCBzaGEyNTY6MmVjY2RiNDM4MjVkMmE0OWQ5OWQ1NDJkYWEyMDA3NWNmZjFkOTdkOWQyMzQ5YTg5NzdlZmU5YzAzNjYxNzM3YwpzaXplIDIwNDgK", - lfsOid: util.ToPointer("2eccdb43825d2a49d99d542daa20075cff1d97d9d2349a8977efe9c03661737c"), - lfsSize: util.ToPointer(int64(2048)), + lfsOid: new("2eccdb43825d2a49d99d542daa20075cff1d97d9d2349a8977efe9c03661737c"), + lfsSize: new(int64(2048)), }, { filename: "jpeg.jpeg", @@ -267,8 +266,8 @@ func getExpectedFileResponseForRepoFilesUpdateRename(commitID, lastCommitSHA str sha: "2b6c6c4eaefa24b22f2092c3d54b263ff26feb58", size: 127, content: "dmVyc2lvbiBodHRwczovL2dpdC1sZnMuZ2l0aHViLmNvbS9zcGVjL3YxCm9pZCBzaGEyNTY6N2I2YjJjODhkYmE5Zjc2MGExYTU4NDY5YjY3ZmVlMmI2OThlZjdlOTM5OWM0Y2E0ZjM0YTE0Y2NiZTM5ZjYyMwpzaXplIDI3Cg==", - lfsOid: util.ToPointer("7b6b2c88dba9f760a1a58469b67fee2b698ef7e9399c4ca4f34a14ccbe39f623"), - lfsSize: util.ToPointer(int64(27)), + lfsOid: new("7b6b2c88dba9f760a1a58469b67fee2b698ef7e9399c4ca4f34a14ccbe39f623"), + lfsSize: new(int64(27)), }, } @@ -283,10 +282,10 @@ func getExpectedFileResponseForRepoFilesUpdateRename(commitID, lastCommitSHA str Name: detail.filename, Path: detail.filename, SHA: detail.sha, - LastCommitSHA: util.ToPointer(lastCommitSHA), + LastCommitSHA: new(lastCommitSHA), Type: "file", Size: detail.size, - Encoding: util.ToPointer("base64"), + Encoding: new("base64"), Content: &detail.content, URL: &selfURL, HTMLURL: &htmlURL,