Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v1.64.6 (forgejo) (#7118)
Some checks failed
/ release (push) Waiting to run
testing / backend-checks (push) Has been skipped
testing / frontend-checks (push) Has been skipped
testing / test-unit (push) Has been skipped
testing / test-e2e (push) Has been skipped
testing / test-mysql (push) Has been skipped
testing / test-pgsql (push) Has been skipped
testing / test-sqlite (push) Has been skipped
testing / test-remote-cacher (redis) (push) Has been skipped
testing / test-remote-cacher (valkey) (push) Has been skipped
testing / test-remote-cacher (garnet) (push) Has been skipped
testing / test-remote-cacher (redict) (push) Has been skipped
testing / security-check (push) Has been skipped
Integration tests for the release process / release-simulation (push) Has been cancelled

Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
This commit is contained in:
Renovate Bot 2025-03-04 21:38:35 +00:00 committed by forgejo-renovate-action
parent bb0e26a7b4
commit 6b436955fc
97 changed files with 258 additions and 345 deletions

View file

@ -14,7 +14,7 @@ import (
func TestReadingBlameOutputSha256(t *testing.T) {
skipIfSHA256NotSupported(t)
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(t.Context())
defer cancel()
t.Run("Without .git-blame-ignore-revs", func(t *testing.T) {

View file

@ -12,7 +12,7 @@ import (
)
func TestReadingBlameOutput(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(t.Context())
defer cancel()
t.Run("Without .git-blame-ignore-revs", func(t *testing.T) {

View file

@ -4,7 +4,6 @@
package git
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
@ -12,13 +11,13 @@ import (
)
func TestRunWithContextStd(t *testing.T) {
cmd := NewCommand(context.Background(), "--version")
cmd := NewCommand(t.Context(), "--version")
stdout, stderr, err := cmd.RunStdString(&RunOpts{})
require.NoError(t, err)
assert.Empty(t, stderr)
assert.Contains(t, stdout, "git version")
cmd = NewCommand(context.Background(), "--no-such-arg")
cmd = NewCommand(t.Context(), "--no-such-arg")
stdout, stderr, err = cmd.RunStdString(&RunOpts{})
if assert.Error(t, err) {
assert.Equal(t, stderr, err.Stderr())
@ -27,16 +26,16 @@ func TestRunWithContextStd(t *testing.T) {
assert.Empty(t, stdout)
}
cmd = NewCommand(context.Background())
cmd = NewCommand(t.Context())
cmd.AddDynamicArguments("-test")
require.ErrorIs(t, cmd.Run(&RunOpts{}), ErrBrokenCommand)
cmd = NewCommand(context.Background())
cmd = NewCommand(t.Context())
cmd.AddDynamicArguments("--test")
require.ErrorIs(t, cmd.Run(&RunOpts{}), ErrBrokenCommand)
subCmd := "version"
cmd = NewCommand(context.Background()).AddDynamicArguments(subCmd) // for test purpose only, the sub-command should never be dynamic for production
cmd = NewCommand(t.Context()).AddDynamicArguments(subCmd) // for test purpose only, the sub-command should never be dynamic for production
stdout, stderr, err = cmd.RunStdString(&RunOpts{})
require.NoError(t, err)
assert.Empty(t, stderr)
@ -55,15 +54,15 @@ func TestGitArgument(t *testing.T) {
}
func TestCommandString(t *testing.T) {
cmd := NewCommandContextNoGlobals(context.Background(), "a", "-m msg", "it's a test", `say "hello"`)
cmd := NewCommandContextNoGlobals(t.Context(), "a", "-m msg", "it's a test", `say "hello"`)
assert.EqualValues(t, cmd.prog+` a "-m msg" "it's a test" "say \"hello\""`, cmd.String())
cmd = NewCommandContextNoGlobals(context.Background(), "url: https://a:b@c/")
cmd = NewCommandContextNoGlobals(t.Context(), "url: https://a:b@c/")
assert.EqualValues(t, cmd.prog+` "url: https://sanitized-credential@c/"`, cmd.toString(true))
}
func TestGrepOnlyFunction(t *testing.T) {
cmd := NewCommand(context.Background(), "anything-but-grep")
cmd := NewCommand(t.Context(), "anything-but-grep")
assert.Panics(t, func() {
cmd.AddGitGrepExpression("whatever")
})

View file

@ -4,7 +4,6 @@
package git
import (
"context"
"path/filepath"
"testing"
"time"
@ -84,7 +83,7 @@ func testGetCommitsInfo(t *testing.T, repo1 *Repository) {
}
// FIXME: Context.TODO() - if graceful has started we should use its Shutdown context otherwise use install signals in TestMain.
commitsInfo, treeCommit, err := entries.GetCommitsInfo(context.TODO(), commit, testCase.Path)
commitsInfo, treeCommit, err := entries.GetCommitsInfo(t.Context(), commit, testCase.Path)
require.NoError(t, err, "Unable to get commit information for entries of subtree: %s in commit: %s from testcase due to error: %v", testCase.Path, testCase.CommitID, err)
if err != nil {
t.FailNow()
@ -161,7 +160,7 @@ func BenchmarkEntries_GetCommitsInfo(b *testing.B) {
b.ResetTimer()
b.Run(benchmark.name, func(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _, err := entries.GetCommitsInfo(context.Background(), commit, "")
_, _, err := entries.GetCommitsInfo(b.Context(), commit, "")
if err != nil {
b.Fatal(err)
}

View file

@ -5,7 +5,6 @@ package git
import (
"bytes"
"context"
"os"
"path"
"path/filepath"
@ -20,7 +19,7 @@ func TestGrepSearch(t *testing.T) {
require.NoError(t, err)
defer repo.Close()
res, err := GrepSearch(context.Background(), repo, "public", GrepOptions{})
res, err := GrepSearch(t.Context(), repo, "public", GrepOptions{})
require.NoError(t, err)
assert.Equal(t, []*GrepResult{
{
@ -43,7 +42,7 @@ func TestGrepSearch(t *testing.T) {
},
}, res)
res, err = GrepSearch(context.Background(), repo, "void", GrepOptions{MaxResultLimit: 1, ContextLineNumber: 2})
res, err = GrepSearch(t.Context(), repo, "void", GrepOptions{MaxResultLimit: 1, ContextLineNumber: 2})
require.NoError(t, err)
assert.Equal(t, []*GrepResult{
{
@ -60,7 +59,7 @@ func TestGrepSearch(t *testing.T) {
},
}, res)
res, err = GrepSearch(context.Background(), repo, "world", GrepOptions{MatchesPerFile: 1})
res, err = GrepSearch(t.Context(), repo, "world", GrepOptions{MatchesPerFile: 1})
require.NoError(t, err)
assert.Equal(t, []*GrepResult{
{
@ -89,7 +88,7 @@ func TestGrepSearch(t *testing.T) {
},
}, res)
res, err = GrepSearch(context.Background(), repo, "world", GrepOptions{
res, err = GrepSearch(t.Context(), repo, "world", GrepOptions{
MatchesPerFile: 1,
Filename: "java-hello/",
})
@ -103,11 +102,11 @@ func TestGrepSearch(t *testing.T) {
},
}, res)
res, err = GrepSearch(context.Background(), repo, "no-such-content", GrepOptions{})
res, err = GrepSearch(t.Context(), repo, "no-such-content", GrepOptions{})
require.NoError(t, err)
assert.Empty(t, res)
res, err = GrepSearch(context.Background(), &Repository{Path: "no-such-git-repo"}, "no-such-content", GrepOptions{})
res, err = GrepSearch(t.Context(), &Repository{Path: "no-such-git-repo"}, "no-such-content", GrepOptions{})
require.Error(t, err)
assert.Empty(t, res)
}
@ -131,7 +130,7 @@ func TestGrepDashesAreFine(t *testing.T) {
err = CommitChanges(tmpDir, CommitChangesOptions{Message: "Dashes are cool sometimes"})
require.NoError(t, err)
res, err := GrepSearch(context.Background(), gitRepo, "--", GrepOptions{})
res, err := GrepSearch(t.Context(), gitRepo, "--", GrepOptions{})
require.NoError(t, err)
assert.Len(t, res, 1)
assert.Equal(t, "with-dashes", res[0].Filename)
@ -156,7 +155,7 @@ func TestGrepNoBinary(t *testing.T) {
err = CommitChanges(tmpDir, CommitChangesOptions{Message: "Binary and text files"})
require.NoError(t, err)
res, err := GrepSearch(context.Background(), gitRepo, "BINARY", GrepOptions{})
res, err := GrepSearch(t.Context(), gitRepo, "BINARY", GrepOptions{})
require.NoError(t, err)
assert.Len(t, res, 1)
assert.Equal(t, "TEXT", res[0].Filename)
@ -180,7 +179,7 @@ func TestGrepLongFiles(t *testing.T) {
err = CommitChanges(tmpDir, CommitChangesOptions{Message: "Long file"})
require.NoError(t, err)
res, err := GrepSearch(context.Background(), gitRepo, "a", GrepOptions{})
res, err := GrepSearch(t.Context(), gitRepo, "a", GrepOptions{})
require.NoError(t, err)
assert.Len(t, res, 1)
assert.Len(t, res[0].LineCodes[0], 65*1024)
@ -210,7 +209,7 @@ func TestGrepRefs(t *testing.T) {
err = CommitChanges(tmpDir, CommitChangesOptions{Message: "add BCD"})
require.NoError(t, err)
res, err := GrepSearch(context.Background(), gitRepo, "a", GrepOptions{RefName: "v1"})
res, err := GrepSearch(t.Context(), gitRepo, "a", GrepOptions{RefName: "v1"})
require.NoError(t, err)
assert.Len(t, res, 1)
assert.Equal(t, "A", res[0].LineCodes[0])
@ -236,12 +235,12 @@ func TestGrepCanHazRegexOnDemand(t *testing.T) {
require.NoError(t, err)
// should find nothing by default...
res, err := GrepSearch(context.Background(), gitRepo, "\\bmatch\\b", GrepOptions{})
res, err := GrepSearch(t.Context(), gitRepo, "\\bmatch\\b", GrepOptions{})
require.NoError(t, err)
assert.Empty(t, res)
// ... unless configured explicitly
res, err = GrepSearch(context.Background(), gitRepo, "\\bmatch\\b", GrepOptions{Mode: RegExpGrepMode})
res, err = GrepSearch(t.Context(), gitRepo, "\\bmatch\\b", GrepOptions{Mode: RegExpGrepMode})
require.NoError(t, err)
assert.Len(t, res, 1)
assert.Equal(t, "matching", res[0].Filename)

View file

@ -4,8 +4,6 @@
package git_test
import (
"context"
"os"
"path/filepath"
"testing"
@ -32,7 +30,7 @@ func TestGetNotes(t *testing.T) {
defer bareRepo1.Close()
note := git.Note{}
err = git.GetNote(context.Background(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", &note)
err = git.GetNote(t.Context(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", &note)
require.NoError(t, err)
assert.Equal(t, []byte("Note contents\n"), note.Message)
assert.Equal(t, "Vladimir Panteleev", note.Commit.Author.Name)
@ -45,10 +43,10 @@ func TestGetNestedNotes(t *testing.T) {
defer repo.Close()
note := git.Note{}
err = git.GetNote(context.Background(), repo, "3e668dbfac39cbc80a9ff9c61eb565d944453ba4", &note)
err = git.GetNote(t.Context(), repo, "3e668dbfac39cbc80a9ff9c61eb565d944453ba4", &note)
require.NoError(t, err)
assert.Equal(t, []byte("Note 2"), note.Message)
err = git.GetNote(context.Background(), repo, "ba0a96fa63532d6c5087ecef070b0250ed72fa47", &note)
err = git.GetNote(t.Context(), repo, "ba0a96fa63532d6c5087ecef070b0250ed72fa47", &note)
require.NoError(t, err)
assert.Equal(t, []byte("Note 1"), note.Message)
}
@ -60,7 +58,7 @@ func TestGetNonExistentNotes(t *testing.T) {
defer bareRepo1.Close()
note := git.Note{}
err = git.GetNote(context.Background(), bareRepo1, "non_existent_sha", &note)
err = git.GetNote(t.Context(), bareRepo1, "non_existent_sha", &note)
require.Error(t, err)
assert.IsType(t, git.ErrNotExist{}, err)
}
@ -68,19 +66,17 @@ func TestGetNonExistentNotes(t *testing.T) {
func TestSetNote(t *testing.T) {
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
tempDir, err := os.MkdirTemp("", "")
require.NoError(t, err)
defer os.RemoveAll(tempDir)
tempDir := t.TempDir()
require.NoError(t, unittest.CopyDir(bareRepo1Path, filepath.Join(tempDir, "repo1")))
bareRepo1, err := openRepositoryWithDefaultContext(filepath.Join(tempDir, "repo1"))
require.NoError(t, err)
defer bareRepo1.Close()
require.NoError(t, git.SetNote(context.Background(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", "This is a new note", "Test", "test@test.com"))
require.NoError(t, git.SetNote(t.Context(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", "This is a new note", "Test", "test@test.com"))
note := git.Note{}
err = git.GetNote(context.Background(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", &note)
err = git.GetNote(t.Context(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", &note)
require.NoError(t, err)
assert.Equal(t, []byte("This is a new note\n"), note.Message)
assert.Equal(t, "Test", note.Commit.Author.Name)
@ -97,10 +93,10 @@ func TestRemoveNote(t *testing.T) {
require.NoError(t, err)
defer bareRepo1.Close()
require.NoError(t, git.RemoveNote(context.Background(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653"))
require.NoError(t, git.RemoveNote(t.Context(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653"))
note := git.Note{}
err = git.GetNote(context.Background(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", &note)
err = git.GetNote(t.Context(), bareRepo1, "95bb4d39648ee7e325106df01a621c530863a653", &note)
require.Error(t, err)
assert.IsType(t, git.ErrNotExist{}, err)
}

View file

@ -14,7 +14,7 @@ import (
// This unit test relies on the implementation detail of CatFileBatch.
func TestCatFileBatch(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(t.Context())
defer cancel()
repo, err := OpenRepository(ctx, "./tests/repos/repo1_bare")
@ -89,7 +89,7 @@ func TestCatFileBatch(t *testing.T) {
// This unit test relies on the implementation detail of CatFileBatchCheck.
func TestCatFileBatchCheck(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
ctx, cancel := context.WithCancel(t.Context())
defer cancel()
repo, err := OpenRepository(ctx, "./tests/repos/repo1_bare")

View file

@ -4,7 +4,6 @@
package git
import (
"context"
"path/filepath"
"testing"
@ -34,21 +33,21 @@ func TestRepoIsEmpty(t *testing.T) {
func TestRepoGetDivergingCommits(t *testing.T) {
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
do, err := GetDivergingCommits(context.Background(), bareRepo1Path, "master", "branch2")
do, err := GetDivergingCommits(t.Context(), bareRepo1Path, "master", "branch2")
require.NoError(t, err)
assert.Equal(t, DivergeObject{
Ahead: 1,
Behind: 5,
}, do)
do, err = GetDivergingCommits(context.Background(), bareRepo1Path, "master", "master")
do, err = GetDivergingCommits(t.Context(), bareRepo1Path, "master", "master")
require.NoError(t, err)
assert.Equal(t, DivergeObject{
Ahead: 0,
Behind: 0,
}, do)
do, err = GetDivergingCommits(context.Background(), bareRepo1Path, "master", "test")
do, err = GetDivergingCommits(t.Context(), bareRepo1Path, "master", "test")
require.NoError(t, err)
assert.Equal(t, DivergeObject{
Ahead: 0,