From 9124d8dbaa4b343c35819953464e053da82c3763 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 19 May 2024 16:00:43 +1000 Subject: [PATCH 1/2] Bump go version to 1.22 --- .github/workflows/cd.yml | 4 ++-- .github/workflows/ci.yml | 17 +++++++++++------ .golangci.yml | 2 +- Dockerfile | 2 +- go.mod | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 0d126d16e23..823f2bc8076 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -3,7 +3,7 @@ name: Continuous Delivery on: push: tags: - - 'v*' + - "v*" jobs: goreleaser: @@ -16,7 +16,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.22.x - name: Run goreleaser uses: goreleaser/goreleaser-action@v4 with: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74033166a36..c0e472727b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,7 @@ name: Continuous Integration env: - GO_VERSION: 1.21 + GO_VERSION: 1.22 on: push: @@ -32,7 +32,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.22.x - name: Test code # we're passing -short so that we skip the integration tests, which will be run in parallel below run: | @@ -89,7 +89,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.22.x - name: Print git version run: git --version - name: Test code @@ -115,7 +115,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.22.x - name: Build linux binary run: | GOOS=linux go build @@ -142,7 +142,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.22.x - name: Check Vendor Directory # ensure our vendor directory matches up with our go modules run: | @@ -168,7 +168,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v4 with: - go-version: 1.21.x + go-version: 1.22.x - name: Lint uses: golangci/golangci-lint-action@v3.7.0 with: @@ -194,6 +194,11 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: 1.22.x + - name: Download all coverage artifacts uses: actions/download-artifact@v3 with: diff --git a/.golangci.yml b/.golangci.yml index c8884c93a8c..85a956508ff 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -30,5 +30,5 @@ linters-settings: max-func-lines: 0 run: - go: '1.21' + go: '1.22' timeout: 10m diff --git a/Dockerfile b/Dockerfile index 976f2221d40..5945044688d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # docker build -t lazygit . # docker run -it lazygit:latest /bin/sh -FROM golang:1.21 as build +FROM golang:1.22 as build WORKDIR /go/src/github.com/jesseduffield/lazygit/ COPY go.mod go.sum ./ RUN go mod download diff --git a/go.mod b/go.mod index e084a07412e..ca0adebe212 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/jesseduffield/lazygit -go 1.21 +go 1.22 require ( github.com/adrg/xdg v0.4.0 From fdff2dec79c30d45af9d3330907f40ebb75b53d4 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 19 May 2024 16:02:16 +1000 Subject: [PATCH 2/2] Remove redundant variable dedeclarations In go 1.22, loop variables are redeclared with each iteration of the loop, rather than simple updated on each iteration. This means that we no longer need to manually redeclare variables when they're closed over by a function. --- pkg/commands/git_commands/branch_test.go | 5 ----- pkg/commands/git_commands/commit_loader.go | 2 -- pkg/commands/git_commands/commit_loader_test.go | 1 - pkg/commands/git_commands/commit_test.go | 8 -------- pkg/commands/git_commands/file_loader_test.go | 1 - pkg/commands/git_commands/flow_test.go | 2 -- pkg/commands/git_commands/rebase_test.go | 3 --- pkg/commands/git_commands/reflog_commit_loader_test.go | 1 - pkg/commands/git_commands/repo_paths_test.go | 1 - pkg/commands/git_commands/stash_loader_test.go | 1 - pkg/commands/git_commands/stash_test.go | 3 --- pkg/commands/git_commands/sync_test.go | 3 --- pkg/commands/git_commands/tag_loader_test.go | 1 - pkg/commands/git_commands/working_tree_test.go | 9 --------- pkg/commands/git_commands/worktree_loader.go | 2 -- pkg/commands/git_commands/worktree_loader_test.go | 1 - pkg/commands/git_config/cached_git_config_test.go | 2 -- pkg/commands/hosting_service/hosting_service_test.go | 1 - pkg/commands/oscommands/os.go | 7 +++---- pkg/commands/patch/patch_test.go | 4 ---- pkg/gui/context/menu_context.go | 1 - pkg/gui/controllers/diffing_menu_action.go | 1 - pkg/gui/controllers/local_commits_controller.go | 1 - pkg/gui/filetree/build_tree_test.go | 4 ---- pkg/gui/filetree/file_node_test.go | 2 -- pkg/gui/filetree/file_tree_test.go | 1 - pkg/gui/mergeconflicts/state_test.go | 1 - pkg/gui/patch_exploring/focus_test.go | 1 - pkg/gui/presentation/commits_test.go | 1 - pkg/gui/presentation/files_test.go | 2 -- pkg/gui/presentation/graph/graph.go | 1 - pkg/gui/presentation/graph/graph_test.go | 2 -- pkg/gui/services/custom_commands/menu_generator_test.go | 1 - pkg/gui/services/custom_commands/resolver.go | 1 - pkg/gui/style/style_test.go | 2 -- pkg/integration/components/runner.go | 2 -- pkg/utils/slice_test.go | 4 ---- pkg/utils/yaml_utils/yaml_utils_test.go | 1 - 38 files changed, 3 insertions(+), 84 deletions(-) diff --git a/pkg/commands/git_commands/branch_test.go b/pkg/commands/git_commands/branch_test.go index a6082586c94..5c58513d0f3 100644 --- a/pkg/commands/git_commands/branch_test.go +++ b/pkg/commands/git_commands/branch_test.go @@ -41,7 +41,6 @@ func TestBranchGetCommitDifferences(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildBranchCommands(commonDeps{runner: s.runner}) pushables, pullables := instance.GetCommitDifferences("HEAD", "@{u}") @@ -89,7 +88,6 @@ func TestBranchDeleteBranch(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildBranchCommands(commonDeps{runner: s.runner}) @@ -150,7 +148,6 @@ func TestBranchMerge(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { runner := oscommands.NewFakeRunner(t). ExpectGitArgs(s.expected, "", nil) @@ -190,7 +187,6 @@ func TestBranchCheckout(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildBranchCommands(commonDeps{runner: s.runner}) s.test(instance.Checkout("test", CheckoutOptions{Force: s.force})) @@ -279,7 +275,6 @@ func TestBranchCurrentBranchInfo(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildBranchCommands(commonDeps{runner: s.runner}) s.test(instance.CurrentBranchInfo()) diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index 3c01344d95a..737e4c07731 100644 --- a/pkg/commands/git_commands/commit_loader.go +++ b/pkg/commands/git_commands/commit_loader.go @@ -505,8 +505,6 @@ func (self *CommitLoader) getExistingMainBranches() []string { for i, branchName := range mainBranches { wg.Add(1) - i := i - branchName := branchName go utils.Safe(func() { defer wg.Done() diff --git a/pkg/commands/git_commands/commit_loader_test.go b/pkg/commands/git_commands/commit_loader_test.go index d9aa8456cb0..fe4f395855a 100644 --- a/pkg/commands/git_commands/commit_loader_test.go +++ b/pkg/commands/git_commands/commit_loader_test.go @@ -303,7 +303,6 @@ func TestGetCommits(t *testing.T) { } for _, scenario := range scenarios { - scenario := scenario t.Run(scenario.testName, func(t *testing.T) { common := utils.NewDummyCommon() common.AppState = &config.AppState{} diff --git a/pkg/commands/git_commands/commit_test.go b/pkg/commands/git_commands/commit_test.go index 2e36636c50a..c3708422ecb 100644 --- a/pkg/commands/git_commands/commit_test.go +++ b/pkg/commands/git_commands/commit_test.go @@ -30,7 +30,6 @@ func TestCommitRewordCommit(t *testing.T) { }, } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildCommitCommands(commonDeps{runner: s.runner}) @@ -100,7 +99,6 @@ func TestCommitCommitCmdObj(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { userConfig := config.GetDefaultConfig() userConfig.Git.Commit.SignOff = s.configSignoff @@ -136,7 +134,6 @@ func TestCommitCommitEditorCmdObj(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { userConfig := config.GetDefaultConfig() userConfig.Git.Commit.SignOff = s.configSignoff @@ -171,7 +168,6 @@ func TestCommitCreateFixupCommit(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildCommitCommands(commonDeps{runner: s.runner}) s.test(instance.CreateFixupCommit(s.hash)) @@ -221,7 +217,6 @@ func TestCommitCreateAmendCommit(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildCommitCommands(commonDeps{runner: s.runner}) err := instance.CreateAmendCommit(s.originalSubject, s.newSubject, s.newDescription, s.includeFileChanges) @@ -285,7 +280,6 @@ func TestCommitShowCmdObj(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { userConfig := config.GetDefaultConfig() userConfig.Git.Paging.ExternalDiffCommand = s.extDiffCmd @@ -334,7 +328,6 @@ func TestGetCommitMsg(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildCommitCommands(commonDeps{ runner: oscommands.NewFakeRunner(t).ExpectGitArgs([]string{"-c", "log.showsignature=false", "log", "--format=%B", "--max-count=1", "deadbeef"}, s.input, nil), @@ -374,7 +367,6 @@ func TestGetCommitMessageFromHistory(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildCommitCommands(commonDeps{runner: s.runner}) diff --git a/pkg/commands/git_commands/file_loader_test.go b/pkg/commands/git_commands/file_loader_test.go index f7efe68b80d..73fac7ef4e7 100644 --- a/pkg/commands/git_commands/file_loader_test.go +++ b/pkg/commands/git_commands/file_loader_test.go @@ -172,7 +172,6 @@ func TestFileGetStatusFiles(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { cmd := oscommands.NewDummyCmdObjBuilder(s.runner) diff --git a/pkg/commands/git_commands/flow_test.go b/pkg/commands/git_commands/flow_test.go index 21729b5a85a..911f50c7eb4 100644 --- a/pkg/commands/git_commands/flow_test.go +++ b/pkg/commands/git_commands/flow_test.go @@ -23,7 +23,6 @@ func TestStartCmdObj(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildFlowCommands(commonDeps{}) @@ -69,7 +68,6 @@ func TestFinishCmdObj(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildFlowCommands(commonDeps{ gitConfig: git_config.NewFakeGitConfig(s.gitConfigMockResponses), diff --git a/pkg/commands/git_commands/rebase_test.go b/pkg/commands/git_commands/rebase_test.go index 2760abd052c..21ebdf365dc 100644 --- a/pkg/commands/git_commands/rebase_test.go +++ b/pkg/commands/git_commands/rebase_test.go @@ -67,7 +67,6 @@ func TestRebaseRebaseBranch(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildRebaseCommands(commonDeps{runner: s.runner, gitVersion: s.gitVersion}) s.test(instance.RebaseBranch(s.arg)) @@ -89,7 +88,6 @@ func TestRebaseSkipEditorCommand(t *testing.T) { `^GIT_SEQUENCE_EDITOR=.*$`, "^" + daemon.DaemonKindEnvKey + "=" + strconv.Itoa(int(daemon.DaemonKindExitImmediately)) + "$", } { - regexStr := regexStr foundMatch := lo.ContainsBy(envVars, func(envVar string) bool { return regexp.MustCompile(regexStr).MatchString(envVar) }) @@ -163,7 +161,6 @@ func TestRebaseDiscardOldFileChanges(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildRebaseCommands(commonDeps{ runner: s.runner, diff --git a/pkg/commands/git_commands/reflog_commit_loader_test.go b/pkg/commands/git_commands/reflog_commit_loader_test.go index ca02f2b51f6..c9eca3e158e 100644 --- a/pkg/commands/git_commands/reflog_commit_loader_test.go +++ b/pkg/commands/git_commands/reflog_commit_loader_test.go @@ -176,7 +176,6 @@ func TestGetReflogCommits(t *testing.T) { } for _, scenario := range scenarios { - scenario := scenario t.Run(scenario.testName, func(t *testing.T) { builder := &ReflogCommitLoader{ Common: utils.NewDummyCommon(), diff --git a/pkg/commands/git_commands/repo_paths_test.go b/pkg/commands/git_commands/repo_paths_test.go index ae452673771..97cfc811908 100644 --- a/pkg/commands/git_commands/repo_paths_test.go +++ b/pkg/commands/git_commands/repo_paths_test.go @@ -101,7 +101,6 @@ func TestGetRepoPaths(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.Name, func(t *testing.T) { runner := oscommands.NewFakeRunner(t) cmd := oscommands.NewDummyCmdObjBuilder(runner) diff --git a/pkg/commands/git_commands/stash_loader_test.go b/pkg/commands/git_commands/stash_loader_test.go index 393b4d4b93b..4f1f171fedf 100644 --- a/pkg/commands/git_commands/stash_loader_test.go +++ b/pkg/commands/git_commands/stash_loader_test.go @@ -47,7 +47,6 @@ func TestGetStashEntries(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { cmd := oscommands.NewDummyCmdObjBuilder(s.runner) diff --git a/pkg/commands/git_commands/stash_test.go b/pkg/commands/git_commands/stash_test.go index 35b48e42db8..accd0589075 100644 --- a/pkg/commands/git_commands/stash_test.go +++ b/pkg/commands/git_commands/stash_test.go @@ -74,7 +74,6 @@ func TestStashStore(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { runner := oscommands.NewFakeRunner(t). ExpectGitArgs(s.expected, "", nil) @@ -131,7 +130,6 @@ func TestStashStashEntryCmdObj(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { userConfig := config.GetDefaultConfig() appState := &config.AppState{} @@ -181,7 +179,6 @@ func TestStashRename(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { runner := oscommands.NewFakeRunner(t). ExpectGitArgs(s.expectedHashCmd, s.hashResult, nil). diff --git a/pkg/commands/git_commands/sync_test.go b/pkg/commands/git_commands/sync_test.go index 93e6de1b160..f5f281e147d 100644 --- a/pkg/commands/git_commands/sync_test.go +++ b/pkg/commands/git_commands/sync_test.go @@ -86,7 +86,6 @@ func TestSyncPush(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildSyncCommands(commonDeps{}) task := gocui.NewFakeTask() @@ -124,7 +123,6 @@ func TestSyncFetch(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildSyncCommands(commonDeps{}) instance.UserConfig.Git.FetchAll = s.fetchAllConfig @@ -163,7 +161,6 @@ func TestSyncFetchBackground(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildSyncCommands(commonDeps{}) instance.UserConfig.Git.FetchAll = s.fetchAllConfig diff --git a/pkg/commands/git_commands/tag_loader_test.go b/pkg/commands/git_commands/tag_loader_test.go index 59c4d0337ab..1d24e9dd108 100644 --- a/pkg/commands/git_commands/tag_loader_test.go +++ b/pkg/commands/git_commands/tag_loader_test.go @@ -44,7 +44,6 @@ func TestGetTags(t *testing.T) { } for _, scenario := range scenarios { - scenario := scenario t.Run(scenario.testName, func(t *testing.T) { loader := &TagLoader{ Common: utils.NewDummyCommon(), diff --git a/pkg/commands/git_commands/working_tree_test.go b/pkg/commands/git_commands/working_tree_test.go index 435048072dc..cc0ad55f5f3 100644 --- a/pkg/commands/git_commands/working_tree_test.go +++ b/pkg/commands/git_commands/working_tree_test.go @@ -61,7 +61,6 @@ func TestWorkingTreeUnstageFile(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildWorkingTreeCommands(commonDeps{runner: s.runner}) s.test(instance.UnStageFile([]string{"test.txt"}, s.reset)) @@ -190,7 +189,6 @@ func TestWorkingTreeDiscardAllFileChanges(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildWorkingTreeCommands(commonDeps{runner: s.runner, removeFile: s.removeFile}) err := instance.DiscardAllFileChanges(s.file) @@ -306,7 +304,6 @@ func TestWorkingTreeDiff(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { userConfig := config.GetDefaultConfig() appState := &config.AppState{} @@ -375,7 +372,6 @@ func TestWorkingTreeShowFileDiff(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { userConfig := config.GetDefaultConfig() appState := &config.AppState{} @@ -428,7 +424,6 @@ func TestWorkingTreeCheckoutFile(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildWorkingTreeCommands(commonDeps{runner: s.runner}) @@ -459,7 +454,6 @@ func TestWorkingTreeDiscardUnstagedFileChanges(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildWorkingTreeCommands(commonDeps{runner: s.runner}) s.test(instance.DiscardUnstagedFileChanges(s.file)) @@ -487,7 +481,6 @@ func TestWorkingTreeDiscardAnyUnstagedFileChanges(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildWorkingTreeCommands(commonDeps{runner: s.runner}) s.test(instance.DiscardAnyUnstagedFileChanges()) @@ -515,7 +508,6 @@ func TestWorkingTreeRemoveUntrackedFiles(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildWorkingTreeCommands(commonDeps{runner: s.runner}) s.test(instance.RemoveUntrackedFiles()) @@ -545,7 +537,6 @@ func TestWorkingTreeResetHard(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { instance := buildWorkingTreeCommands(commonDeps{runner: s.runner}) s.test(instance.ResetHard(s.ref)) diff --git a/pkg/commands/git_commands/worktree_loader.go b/pkg/commands/git_commands/worktree_loader.go index 97839662cab..a6c39dbce0c 100644 --- a/pkg/commands/git_commands/worktree_loader.go +++ b/pkg/commands/git_commands/worktree_loader.go @@ -76,8 +76,6 @@ func (self *WorktreeLoader) GetWorktrees() ([]*models.Worktree, error) { wg := sync.WaitGroup{} wg.Add(len(worktrees)) for _, worktree := range worktrees { - worktree := worktree - go utils.Safe(func() { defer wg.Done() diff --git a/pkg/commands/git_commands/worktree_loader_test.go b/pkg/commands/git_commands/worktree_loader_test.go index 02ed73e865b..ba462729f09 100644 --- a/pkg/commands/git_commands/worktree_loader_test.go +++ b/pkg/commands/git_commands/worktree_loader_test.go @@ -181,7 +181,6 @@ branch refs/heads/mybranch-worktree } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { runner := oscommands.NewFakeRunner(t) fs := afero.NewMemMapFs() diff --git a/pkg/commands/git_config/cached_git_config_test.go b/pkg/commands/git_config/cached_git_config_test.go index 6ba2c5b91b6..fd884df6528 100644 --- a/pkg/commands/git_config/cached_git_config_test.go +++ b/pkg/commands/git_config/cached_git_config_test.go @@ -50,7 +50,6 @@ func TestGetBool(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { fake := NewFakeGitConfig(s.mockResponses) real := NewCachedGitConfig( @@ -87,7 +86,6 @@ func TestGet(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { fake := NewFakeGitConfig(s.mockResponses) real := NewCachedGitConfig( diff --git a/pkg/commands/hosting_service/hosting_service_test.go b/pkg/commands/hosting_service/hosting_service_test.go index c5968c4cd79..20632e983d8 100644 --- a/pkg/commands/hosting_service/hosting_service_test.go +++ b/pkg/commands/hosting_service/hosting_service_test.go @@ -413,7 +413,6 @@ func TestGetPullRequestURL(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { tr := i18n.EnglishTranslationSet() log := &fakes.FakeFieldLogger{} diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go index fc13eedf0d2..0a6bf7397c9 100644 --- a/pkg/commands/oscommands/os.go +++ b/pkg/commands/oscommands/os.go @@ -239,14 +239,13 @@ func (c *OSCommand) PipeCommands(cmdObjs ...ICmdObj) error { wg.Add(len(cmds)) for _, cmd := range cmds { - currentCmd := cmd go utils.Safe(func() { - stderr, err := currentCmd.StderrPipe() + stderr, err := cmd.StderrPipe() if err != nil { c.Log.Error(err) } - if err := currentCmd.Start(); err != nil { + if err := cmd.Start(); err != nil { c.Log.Error(err) } @@ -256,7 +255,7 @@ func (c *OSCommand) PipeCommands(cmdObjs ...ICmdObj) error { } } - if err := currentCmd.Wait(); err != nil { + if err := cmd.Wait(); err != nil { c.Log.Error(err) } diff --git a/pkg/commands/patch/patch_test.go b/pkg/commands/patch/patch_test.go index e86c5f07a85..fc166cbae46 100644 --- a/pkg/commands/patch/patch_test.go +++ b/pkg/commands/patch/patch_test.go @@ -509,7 +509,6 @@ func TestTransform(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { lineIndices := ExpandRange(s.firstLineIndex, s.lastLineIndex) @@ -566,7 +565,6 @@ func TestParseAndFormatPlain(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { // here we parse the patch, then format it, and ensure the result // matches the original patch. Note that unified diffs allow omitting @@ -604,7 +602,6 @@ func TestLineNumberOfLine(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { for i, idx := range s.indexes { patch := Parse(s.patchStr) @@ -633,7 +630,6 @@ func TestGetNextStageableLineIndex(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { for i, idx := range s.indexes { patch := Parse(s.patchStr) diff --git a/pkg/gui/context/menu_context.go b/pkg/gui/context/menu_context.go index e4c3d728024..a6b0e77cbc8 100644 --- a/pkg/gui/context/menu_context.go +++ b/pkg/gui/context/menu_context.go @@ -105,7 +105,6 @@ func (self *MenuViewModel) GetNonModelItems() []*NonModelItem { menuItems := self.FilteredListViewModel.GetItems() var prevSection *types.MenuSection = nil for i, menuItem := range menuItems { - menuItem := menuItem if menuItem.Section != nil && menuItem.Section != prevSection { if prevSection != nil { result = append(result, &NonModelItem{ diff --git a/pkg/gui/controllers/diffing_menu_action.go b/pkg/gui/controllers/diffing_menu_action.go index ec4006b1a71..be44e471bea 100644 --- a/pkg/gui/controllers/diffing_menu_action.go +++ b/pkg/gui/controllers/diffing_menu_action.go @@ -17,7 +17,6 @@ func (self *DiffingMenuAction) Call() error { menuItems := []*types.MenuItem{} for _, name := range names { - name := name menuItems = append(menuItems, []*types.MenuItem{ { Label: fmt.Sprintf("%s %s", self.c.Tr.Diff, name), diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 1121e141e3b..53a6b205f29 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -801,7 +801,6 @@ func (self *LocalCommitsController) revert(commit *models.Commit) error { func (self *LocalCommitsController) createRevertMergeCommitMenu(commit *models.Commit) error { menuItems := make([]*types.MenuItem, len(commit.Parents)) for i, parentHash := range commit.Parents { - i := i message, err := self.c.Git().Commit.GetCommitMessageFirstLine(parentHash) if err != nil { return err diff --git a/pkg/gui/filetree/build_tree_test.go b/pkg/gui/filetree/build_tree_test.go index b2bf20f1d67..eab8babc248 100644 --- a/pkg/gui/filetree/build_tree_test.go +++ b/pkg/gui/filetree/build_tree_test.go @@ -147,7 +147,6 @@ func TestBuildTreeFromFiles(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { result := BuildTreeFromFiles(s.files) assert.EqualValues(t, s.expected, result) @@ -306,7 +305,6 @@ func TestBuildFlatTreeFromFiles(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { result := BuildFlatTreeFromFiles(s.files) assert.EqualValues(t, s.expected, result) @@ -420,7 +418,6 @@ func TestBuildTreeFromCommitFiles(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { result := BuildTreeFromCommitFiles(s.files) assert.EqualValues(t, s.expected, result) @@ -521,7 +518,6 @@ func TestBuildFlatTreeFromCommitFiles(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { result := BuildFlatTreeFromCommitFiles(s.files) assert.EqualValues(t, s.expected, result) diff --git a/pkg/gui/filetree/file_node_test.go b/pkg/gui/filetree/file_node_test.go index a3b2b9aeeaf..c32f0e666d9 100644 --- a/pkg/gui/filetree/file_node_test.go +++ b/pkg/gui/filetree/file_node_test.go @@ -125,7 +125,6 @@ func TestCompress(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { s.root.Compress() assert.EqualValues(t, s.expected, s.root) @@ -155,7 +154,6 @@ func TestGetFile(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { assert.EqualValues(t, s.expected, s.viewModel.GetFile(s.path)) }) diff --git a/pkg/gui/filetree/file_tree_test.go b/pkg/gui/filetree/file_tree_test.go index 32c1104258a..856d25f9a98 100644 --- a/pkg/gui/filetree/file_tree_test.go +++ b/pkg/gui/filetree/file_tree_test.go @@ -71,7 +71,6 @@ func TestFilterAction(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { mngr := &FileTree{getFiles: func() []*models.File { return s.files }, filter: s.filter} result := mngr.getFilesForDisplay() diff --git a/pkg/gui/mergeconflicts/state_test.go b/pkg/gui/mergeconflicts/state_test.go index 861833d32cc..7a9ee8c2691 100644 --- a/pkg/gui/mergeconflicts/state_test.go +++ b/pkg/gui/mergeconflicts/state_test.go @@ -115,7 +115,6 @@ baz } for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { assert.EqualValues(t, s.expected, findConflicts(s.content)) }) diff --git a/pkg/gui/patch_exploring/focus_test.go b/pkg/gui/patch_exploring/focus_test.go index bbe4b234198..aa02fa2bfac 100644 --- a/pkg/gui/patch_exploring/focus_test.go +++ b/pkg/gui/patch_exploring/focus_test.go @@ -122,7 +122,6 @@ func TestNewOrigin(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { assert.EqualValues(t, s.expected, calculateOrigin(s.origin, s.bufferHeight, s.numLines, s.firstLineIdx, s.lastLineIdx, s.selectedLineIdx, s.selectMode)) }) diff --git a/pkg/gui/presentation/commits_test.go b/pkg/gui/presentation/commits_test.go index 53101cb6de2..edf147b9213 100644 --- a/pkg/gui/presentation/commits_test.go +++ b/pkg/gui/presentation/commits_test.go @@ -575,7 +575,6 @@ func TestGetCommitListDisplayStrings(t *testing.T) { common := utils.NewDummyCommon() for _, s := range scenarios { - s := s if !focusing || s.focus { t.Run(s.testName, func(t *testing.T) { result := GetCommitListDisplayStrings( diff --git a/pkg/gui/presentation/files_test.go b/pkg/gui/presentation/files_test.go index 6662c773257..f041991412f 100644 --- a/pkg/gui/presentation/files_test.go +++ b/pkg/gui/presentation/files_test.go @@ -66,7 +66,6 @@ M file1 defer color.ForceSetColorLevel(oldColorLevel) for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { viewModel := filetree.NewFileTree(func() []*models.File { return s.files }, utils.NewDummyLog(), true) viewModel.SetTree() @@ -128,7 +127,6 @@ M file1 defer color.ForceSetColorLevel(oldColorLevel) for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { viewModel := filetree.NewCommitFileTreeViewModel(func() []*models.CommitFile { return s.files }, utils.NewDummyLog(), true) viewModel.SetRef(&models.Commit{}) diff --git a/pkg/gui/presentation/graph/graph.go b/pkg/gui/presentation/graph/graph.go index 8133fd9b686..7f3eb8a2726 100644 --- a/pkg/gui/presentation/graph/graph.go +++ b/pkg/gui/presentation/graph/graph.go @@ -84,7 +84,6 @@ func RenderAux(pipeSets [][]*Pipe, commits []*models.Commit, selectedCommitHash wg.Add(maxProcs) for i := 0; i < maxProcs; i++ { - i := i go func() { from := i * perProc to := (i + 1) * perProc diff --git a/pkg/gui/presentation/graph/graph_test.go b/pkg/gui/presentation/graph/graph_test.go index 57df5489254..39f4400da20 100644 --- a/pkg/gui/presentation/graph/graph_test.go +++ b/pkg/gui/presentation/graph/graph_test.go @@ -217,7 +217,6 @@ func TestRenderCommitGraph(t *testing.T) { defer color.ForceSetColorLevel(oldColorLevel) for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { getStyle := func(c *models.Commit) style.TextStyle { return style.FgDefault } lines := RenderCommitGraph(test.commits, "blah", getStyle) @@ -454,7 +453,6 @@ func TestRenderPipeSet(t *testing.T) { defer color.ForceSetColorLevel(oldColorLevel) for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { actualStr := renderPipeSet(test.pipes, "selected", test.prevCommit) t.Log("actual cells:") diff --git a/pkg/gui/services/custom_commands/menu_generator_test.go b/pkg/gui/services/custom_commands/menu_generator_test.go index c17f7e93acc..81480d1d836 100644 --- a/pkg/gui/services/custom_commands/menu_generator_test.go +++ b/pkg/gui/services/custom_commands/menu_generator_test.go @@ -81,7 +81,6 @@ func TestMenuGenerator(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { s.test(NewMenuGenerator(utils.NewDummyCommon()).call(s.cmdOut, s.filter, s.valueFormat, s.labelFormat)) }) diff --git a/pkg/gui/services/custom_commands/resolver.go b/pkg/gui/services/custom_commands/resolver.go index 67dd7be2de0..bf269735562 100644 --- a/pkg/gui/services/custom_commands/resolver.go +++ b/pkg/gui/services/custom_commands/resolver.go @@ -72,7 +72,6 @@ func (self *Resolver) resolvePrompt( func (self *Resolver) resolveMenuOptions(prompt *config.CustomCommandPrompt, resolveTemplate func(string) (string, error)) ([]config.CustomCommandMenuOption, error) { newOptions := make([]config.CustomCommandMenuOption, 0, len(prompt.Options)) for _, option := range prompt.Options { - option := option newOption, err := self.resolveMenuOption(&option, resolveTemplate) if err != nil { return nil, err diff --git a/pkg/gui/style/style_test.go b/pkg/gui/style/style_test.go index 12fec4287cf..10e88883b71 100644 --- a/pkg/gui/style/style_test.go +++ b/pkg/gui/style/style_test.go @@ -161,7 +161,6 @@ func TestMerge(t *testing.T) { defer color.ForceSetColorLevel(oldColorLevel) for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { style := New() for _, other := range s.toMerge { @@ -212,7 +211,6 @@ func TestTemplateFuncMapAddColors(t *testing.T) { defer color.ForceSetColorLevel(oldColorLevel) for _, s := range scenarios { - s := s t.Run(s.name, func(t *testing.T) { tmpl, err := template.New("test template").Funcs(TemplateFuncMapAddColors(template.FuncMap{})).Parse(s.tmpl) assert.NoError(t, err) diff --git a/pkg/integration/components/runner.go b/pkg/integration/components/runner.go index c148dc14163..f123182cf42 100644 --- a/pkg/integration/components/runner.go +++ b/pkg/integration/components/runner.go @@ -48,8 +48,6 @@ func RunTests(args RunTestArgs) error { } for _, test := range args.Tests { - test := test - args.TestWrapper(test, func() error { //nolint: thelper paths := NewPaths( filepath.Join(testDir, test.Name()), diff --git a/pkg/utils/slice_test.go b/pkg/utils/slice_test.go index b3cad8885a0..df6a89141a0 100644 --- a/pkg/utils/slice_test.go +++ b/pkg/utils/slice_test.go @@ -49,7 +49,6 @@ func TestNextIndex(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { assert.EqualValues(t, s.expected, NextIndex(s.list, s.element)) }) @@ -93,7 +92,6 @@ func TestPrevIndex(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { assert.EqualValues(t, s.expected, PrevIndex(s.list, s.element)) }) @@ -126,7 +124,6 @@ func TestEscapeSpecialChars(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { assert.EqualValues(t, s.expected, EscapeSpecialChars(s.input)) }) @@ -303,7 +300,6 @@ func TestMoveElement(t *testing.T) { } for _, s := range scenarios { - s := s t.Run(s.testName, func(t *testing.T) { assert.EqualValues(t, s.expected, MoveElement(s.list, s.from, s.to)) }) diff --git a/pkg/utils/yaml_utils/yaml_utils_test.go b/pkg/utils/yaml_utils/yaml_utils_test.go index 78e181d85e5..a65f0abf897 100644 --- a/pkg/utils/yaml_utils/yaml_utils_test.go +++ b/pkg/utils/yaml_utils/yaml_utils_test.go @@ -102,7 +102,6 @@ func TestUpdateYamlValue(t *testing.T) { } for _, test := range tests { - test := test t.Run(test.name, func(t *testing.T) { out, actualErr := UpdateYamlValue([]byte(test.in), test.path, test.value) if test.expectedErr == "" {