From 73566c9acb1a885d52fddaefe725c9a1fc150162 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 9 Mar 2026 22:42:35 +0100 Subject: [PATCH 1/2] go: bump to 1.26.1, fix test style, verify lint - Bump go.mod from 1.26.0 to 1.26.1 (security patch) - Refactor TestMatchIssuesEvent to use tagged switch on tc.eventType - Run make tidy, fmt, lint-go --- Makefile | 2 +- go.mod | 2 +- modules/actions/workflows_test.go | 12 ++++-------- tests/integration/api_packages_conan_test.go | 7 ++++--- tests/integration/api_packages_generic_test.go | 7 ++++--- tests/integration/api_releases_test.go | 2 +- tests/integration/api_repo_get_contents_test.go | 2 +- tests/integration/api_token_test.go | 7 ++++--- tests/integration/pull_comment_test.go | 2 +- tests/integration/repo_test.go | 5 +++-- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 280aa853b8e06..393b27dc9ea51 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,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.10.1 +GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.2 GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.15 MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.8.0 SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1 diff --git a/go.mod b/go.mod index c85c4c0b3991d..f0bb361f2da9e 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module code.gitea.io/gitea -go 1.26.0 +go 1.26.1 // 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/modules/actions/workflows_test.go b/modules/actions/workflows_test.go index ea027366f7eb5..15d50f70fdb2a 100644 --- a/modules/actions/workflows_test.go +++ b/modules/actions/workflows_test.go @@ -389,14 +389,10 @@ func TestMatchIssuesEvent(t *testing.T) { // Determine expected action for single event case var expectedAction string - switch tc.payload.Action { - case api.HookIssueLabelUpdated: - if tc.eventType == "labeled" { - expectedAction = "labeled" - } else if tc.eventType == "unlabeled" { - expectedAction = "unlabeled" - } - case api.HookIssueLabelCleared: + switch tc.eventType { + case "labeled": + expectedAction = "labeled" + case "unlabeled": expectedAction = "unlabeled" default: expectedAction = string(tc.payload.Action) diff --git a/tests/integration/api_packages_conan_test.go b/tests/integration/api_packages_conan_test.go index 2223b9bbac1f4..ad8fcdc80ccc9 100644 --- a/tests/integration/api_packages_conan_test.go +++ b/tests/integration/api_packages_conan_test.go @@ -346,15 +346,16 @@ func TestPackageConan(t *testing.T) { pb, err := packages.GetBlobByID(t.Context(), pf.BlobID) assert.NoError(t, err) - if pf.Name == conanfileName { + switch pf.Name { + case conanfileName: assert.True(t, pf.IsLead) assert.Equal(t, int64(len(buildConanfileContent(name, version1))), pb.Size) - } else if pf.Name == conaninfoName { + case conaninfoName: assert.False(t, pf.IsLead) assert.Equal(t, int64(len(contentConaninfo)), pb.Size) - } else { + default: assert.FailNow(t, "unknown file", "unknown file: %s", pf.Name) } } diff --git a/tests/integration/api_packages_generic_test.go b/tests/integration/api_packages_generic_test.go index 5e368967eefbe..c7eb4486d291d 100644 --- a/tests/integration/api_packages_generic_test.go +++ b/tests/integration/api_packages_generic_test.go @@ -140,11 +140,12 @@ func TestPackageGeneric(t *testing.T) { t.Run("ServeDirect", func(t *testing.T) { defer tests.PrintCurrentTest(t)() - if setting.Packages.Storage.Type == setting.MinioStorageType { + switch setting.Packages.Storage.Type { + case setting.MinioStorageType: defer test.MockVariableValue(&setting.Packages.Storage.MinioConfig.ServeDirect, true)() - } else if setting.Packages.Storage.Type == setting.AzureBlobStorageType { + case setting.AzureBlobStorageType: defer test.MockVariableValue(&setting.Packages.Storage.AzureBlobConfig.ServeDirect, true)() - } else { + default: t.Skip("Test skipped for non-Minio-storage and non-AzureBlob-storage.") } diff --git a/tests/integration/api_releases_test.go b/tests/integration/api_releases_test.go index c7f1343dde278..9a5bf2b4379ea 100644 --- a/tests/integration/api_releases_test.go +++ b/tests/integration/api_releases_test.go @@ -422,7 +422,7 @@ func TestAPIUploadAssetRelease(t *testing.T) { defer tests.PrintCurrentTest(t)() const filename = "image.png" - performUpload := func(t *testing.T, uploadURL string, buf []byte, expectedStatus int) *httptest.ResponseRecorder { + performUpload := func(t *testing.T, uploadURL string, _ []byte, _ int) *httptest.ResponseRecorder { body := &bytes.Buffer{} writer := multipart.NewWriter(body) part, err := writer.CreateFormFile("attachment", filename) diff --git a/tests/integration/api_repo_get_contents_test.go b/tests/integration/api_repo_get_contents_test.go index 33960b1ea3d1c..251816950b3d1 100644 --- a/tests/integration/api_repo_get_contents_test.go +++ b/tests/integration/api_repo_get_contents_test.go @@ -60,7 +60,7 @@ func TestAPIGetContents(t *testing.T) { }) } -func testAPIGetContents(t *testing.T, u *url.URL) { +func testAPIGetContents(t *testing.T, _ *url.URL) { /*** SETUP ***/ user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) // owner of the repo1 & repo16 org3 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 3}) // owner of the repo3, is an org diff --git a/tests/integration/api_token_test.go b/tests/integration/api_token_test.go index 75fef9cc4eeb7..91c05e5085d08 100644 --- a/tests/integration/api_token_test.go +++ b/tests/integration/api_token_test.go @@ -502,11 +502,12 @@ func runTestCase(t *testing.T, testCase *requiredScopeTestCase, user *user_model } unauthorizedLevel := auth_model.Write if categoryIsRequired { - if minRequiredLevel == auth_model.Read { + switch minRequiredLevel { + case auth_model.Read: unauthorizedLevel = auth_model.NoAccess - } else if minRequiredLevel == auth_model.Write { + case auth_model.Write: unauthorizedLevel = auth_model.Read - } else { + default: assert.FailNow(t, "Invalid test case", "Unknown access token scope level: %v", minRequiredLevel) } } diff --git a/tests/integration/pull_comment_test.go b/tests/integration/pull_comment_test.go index cb4c70930b099..56ef9972adc33 100644 --- a/tests/integration/pull_comment_test.go +++ b/tests/integration/pull_comment_test.go @@ -74,7 +74,7 @@ func testPullCommentRebase(t *testing.T, u *url.URL, session *TestSession) { assert.True(t, lastComment.IsForcePush) } -func testPullCommentRetarget(t *testing.T, u *url.URL, session *TestSession) { +func testPullCommentRetarget(t *testing.T, _ *url.URL, session *TestSession) { testPRTitle := "Test PR for retarget comment" // keep a non-conflict branch testCreateBranch(t, session, "user2", "repo1", "branch/test-branch/retarget", "test-branch/retarget-no-conflict", http.StatusSeeOther) diff --git a/tests/integration/repo_test.go b/tests/integration/repo_test.go index e88b6b62249da..1841598285fde 100644 --- a/tests/integration/repo_test.go +++ b/tests/integration/repo_test.go @@ -92,9 +92,10 @@ func testViewRepoWithCache(t *testing.T) { tds := s.Find(".repo-file-cell") var f file tds.Each(func(i int, s *goquery.Selection) { - if i == 0 { + switch i { + case 0: f.fileName = strings.TrimSpace(s.Text()) - } else if i == 1 { + case 1: a := s.Find("a") f.commitMsg = strings.TrimSpace(a.Text()) l, _ := a.Attr("href") From 4745034a7c35c222df2e1db78a7c164c445bbdd3 Mon Sep 17 00:00:00 2001 From: silverwind Date: Tue, 10 Mar 2026 06:50:38 +0100 Subject: [PATCH 2/2] Revert semantic change in TestMatchIssuesEvent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restore the original switch on tc.payload.Action which explicitly handles the HookIssueLabelCleared → "unlabeled" mapping, preserving the domain logic relationship. Co-Authored-By: Claude (Opus 4.6) --- modules/actions/workflows_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/actions/workflows_test.go b/modules/actions/workflows_test.go index 15d50f70fdb2a..ea027366f7eb5 100644 --- a/modules/actions/workflows_test.go +++ b/modules/actions/workflows_test.go @@ -389,10 +389,14 @@ func TestMatchIssuesEvent(t *testing.T) { // Determine expected action for single event case var expectedAction string - switch tc.eventType { - case "labeled": - expectedAction = "labeled" - case "unlabeled": + switch tc.payload.Action { + case api.HookIssueLabelUpdated: + if tc.eventType == "labeled" { + expectedAction = "labeled" + } else if tc.eventType == "unlabeled" { + expectedAction = "unlabeled" + } + case api.HookIssueLabelCleared: expectedAction = "unlabeled" default: expectedAction = string(tc.payload.Action)