diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 99ea1128030..6b6cbcd52ca 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,10 +49,9 @@ jobs: fail-fast: false matrix: git-version: - - 2.22.0 # oldest supported version - - 2.23.0 - - 2.25.1 - - 2.30.8 + - 2.32.0 # oldest supported version + - 2.38.2 # first version that supports the rebase.updateRefs config + - 2.44.0 - latest # We rely on github to have the latest version installed on their VMs runs-on: ubuntu-latest name: "Integration Tests - git ${{matrix.git-version}}" diff --git a/pkg/app/app.go b/pkg/app/app.go index ad0d487ece2..914832b8316 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -148,7 +148,7 @@ func (app *App) validateGitVersion() (*git_commands.GitVersion, error) { return nil, minVersionError } - if version.IsOlderThan(2, 22, 0) { + if version.IsOlderThan(2, 32, 0) { return nil, minVersionError } diff --git a/pkg/commands/git_commands/commit_loader.go b/pkg/commands/git_commands/commit_loader.go index 49d43290d91..4a899379f27 100644 --- a/pkg/commands/git_commands/commit_loader.go +++ b/pkg/commands/git_commands/commit_loader.go @@ -249,8 +249,7 @@ func (self *CommitLoader) extractCommitFromLine(hashPool *utils.StringPool, line } func (self *CommitLoader) getHydratedRebasingCommits(hashPool *utils.StringPool, addConflictingCommit bool) ([]*models.Commit, error) { - todoFileHasShortHashes := self.version.IsOlderThan(2, 25, 2) - return self.getHydratedTodoCommits(hashPool, self.getRebasingCommits(hashPool, addConflictingCommit), todoFileHasShortHashes) + return self.getHydratedTodoCommits(hashPool, self.getRebasingCommits(hashPool, addConflictingCommit), false) } func (self *CommitLoader) getHydratedSequencerCommits(hashPool *utils.StringPool, workingTreeState models.WorkingTreeState) ([]*models.Commit, error) { diff --git a/pkg/commands/git_commands/rebase.go b/pkg/commands/git_commands/rebase.go index 8c52dc62f8a..d882d9b1a9a 100644 --- a/pkg/commands/git_commands/rebase.go +++ b/pkg/commands/git_commands/rebase.go @@ -218,7 +218,7 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(opts PrepareInteract Arg("--interactive"). Arg("--autostash"). Arg("--keep-empty"). - ArgIf(opts.keepCommitsThatBecomeEmpty && self.version.IsAtLeast(2, 26, 0), "--empty=keep"). + ArgIf(opts.keepCommitsThatBecomeEmpty, "--empty=keep"). Arg("--no-autosquash"). Arg("--rebase-merges"). ArgIf(opts.onto != "", "--onto", opts.onto). diff --git a/pkg/commands/git_commands/repo_paths.go b/pkg/commands/git_commands/repo_paths.go index 543ab5cd037..c64debfc5aa 100644 --- a/pkg/commands/git_commands/repo_paths.go +++ b/pkg/commands/git_commands/repo_paths.go @@ -21,8 +21,6 @@ type RepoPaths struct { isBareRepo bool } -var gitPathFormatVersion = GitVersion{2, 31, 0, ""} - // Path to the current worktree. If we're in the main worktree, this will // be the same as RepoPath() func (self *RepoPaths) WorktreePath() string { @@ -79,15 +77,14 @@ func GetRepoPaths( if err != nil { return nil, err } - return GetRepoPathsForDir(cwd, cmd, version) + return GetRepoPathsForDir(cwd, cmd) } func GetRepoPathsForDir( dir string, cmd oscommands.ICmdObjBuilder, - version *GitVersion, ) (*RepoPaths, error) { - gitDirOutput, err := callGitRevParseWithDir(cmd, version, dir, "--show-toplevel", "--absolute-git-dir", "--git-common-dir", "--is-bare-repository", "--show-superproject-working-tree") + gitDirOutput, err := callGitRevParseWithDir(cmd, dir, "--show-toplevel", "--absolute-git-dir", "--git-common-dir", "--is-bare-repository", "--show-superproject-working-tree") if err != nil { return nil, err } @@ -96,12 +93,6 @@ func GetRepoPathsForDir( worktreePath := gitDirResults[0] worktreeGitDirPath := gitDirResults[1] repoGitDirPath := gitDirResults[2] - if version.IsOlderThanVersion(&gitPathFormatVersion) { - repoGitDirPath, err = filepath.Abs(repoGitDirPath) - if err != nil { - return nil, err - } - } isBareRepo := gitDirResults[3] == "true" // If we're in a submodule, --show-superproject-working-tree will return @@ -131,11 +122,10 @@ func GetRepoPathsForDir( func callGitRevParseWithDir( cmd oscommands.ICmdObjBuilder, - version *GitVersion, dir string, gitRevArgs ...string, ) (string, error) { - gitRevParse := NewGitCmd("rev-parse").ArgIf(version.IsAtLeastVersion(&gitPathFormatVersion), "--path-format=absolute").Arg(gitRevArgs...) + gitRevParse := NewGitCmd("rev-parse").Arg("--path-format=absolute").Arg(gitRevArgs...) if dir != "" { gitRevParse.Dir(dir) } diff --git a/pkg/commands/git_commands/repo_paths_test.go b/pkg/commands/git_commands/repo_paths_test.go index 2d02a9ed300..29c40acee90 100644 --- a/pkg/commands/git_commands/repo_paths_test.go +++ b/pkg/commands/git_commands/repo_paths_test.go @@ -194,22 +194,13 @@ func TestGetRepoPaths(t *testing.T) { runner := oscommands.NewFakeRunner(t) cmd := oscommands.NewDummyCmdObjBuilder(runner) - version, err := GetGitVersion(oscommands.NewDummyOSCommand()) - if err != nil { - t.Fatal(err) - } - getRevParseArgs := func() []string { - args := []string{"rev-parse"} - if version.IsAtLeast(2, 31, 0) { - args = append(args, "--path-format=absolute") - } - return args + return []string{"rev-parse", "--path-format=absolute"} } // prepare the filesystem for the scenario s.BeforeFunc(runner, getRevParseArgs) - repoPaths, err := GetRepoPathsForDir("", cmd, version) + repoPaths, err := GetRepoPathsForDir("", cmd) // check the error and the paths if s.Err != nil { diff --git a/pkg/commands/git_commands/sync.go b/pkg/commands/git_commands/sync.go index 63fcb9602da..0f5559a7b78 100644 --- a/pkg/commands/git_commands/sync.go +++ b/pkg/commands/git_commands/sync.go @@ -59,7 +59,7 @@ func (self *SyncCommands) fetchCommandBuilder(fetchAll bool) *GitCommandBuilder ArgIf(fetchAll, "--all"). // avoid writing to .git/FETCH_HEAD; this allows running a pull // concurrently without getting errors - ArgIf(self.version.IsAtLeast(2, 29, 0), "--no-write-fetch-head") + Arg("--no-write-fetch-head") } func (self *SyncCommands) FetchCmdObj(task gocui.Task) *oscommands.CmdObj { diff --git a/pkg/commands/git_commands/sync_test.go b/pkg/commands/git_commands/sync_test.go index 8653f8d3cc2..4254788d8ed 100644 --- a/pkg/commands/git_commands/sync_test.go +++ b/pkg/commands/git_commands/sync_test.go @@ -119,7 +119,7 @@ func TestSyncFetch(t *testing.T) { test: func(cmdObj *oscommands.CmdObj) { assert.True(t, cmdObj.ShouldLog()) assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.PROMPT) - assert.Equal(t, cmdObj.Args(), []string{"git", "fetch"}) + assert.Equal(t, cmdObj.Args(), []string{"git", "fetch", "--no-write-fetch-head"}) }, }, { @@ -128,7 +128,7 @@ func TestSyncFetch(t *testing.T) { test: func(cmdObj *oscommands.CmdObj) { assert.True(t, cmdObj.ShouldLog()) assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.PROMPT) - assert.Equal(t, cmdObj.Args(), []string{"git", "fetch", "--all"}) + assert.Equal(t, cmdObj.Args(), []string{"git", "fetch", "--all", "--no-write-fetch-head"}) }, }, } @@ -157,7 +157,7 @@ func TestSyncFetchBackground(t *testing.T) { test: func(cmdObj *oscommands.CmdObj) { assert.False(t, cmdObj.ShouldLog()) assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.FAIL) - assert.Equal(t, cmdObj.Args(), []string{"git", "fetch"}) + assert.Equal(t, cmdObj.Args(), []string{"git", "fetch", "--no-write-fetch-head"}) }, }, { @@ -166,7 +166,7 @@ func TestSyncFetchBackground(t *testing.T) { test: func(cmdObj *oscommands.CmdObj) { assert.False(t, cmdObj.ShouldLog()) assert.Equal(t, cmdObj.GetCredentialStrategy(), oscommands.FAIL) - assert.Equal(t, cmdObj.Args(), []string{"git", "fetch", "--all"}) + assert.Equal(t, cmdObj.Args(), []string{"git", "fetch", "--all", "--no-write-fetch-head"}) }, }, } diff --git a/pkg/commands/git_commands/worktree_loader.go b/pkg/commands/git_commands/worktree_loader.go index a6c39dbce0c..42881f2fc7a 100644 --- a/pkg/commands/git_commands/worktree_loader.go +++ b/pkg/commands/git_commands/worktree_loader.go @@ -82,7 +82,7 @@ func (self *WorktreeLoader) GetWorktrees() ([]*models.Worktree, error) { if worktree.IsPathMissing { return } - gitDir, err := callGitRevParseWithDir(self.cmd, self.version, worktree.Path, "--absolute-git-dir") + gitDir, err := callGitRevParseWithDir(self.cmd, worktree.Path, "--absolute-git-dir") if err != nil { self.Log.Warnf("Could not find git dir for worktree %s: %v", worktree.Path, err) return diff --git a/pkg/commands/git_commands/worktree_loader_test.go b/pkg/commands/git_commands/worktree_loader_test.go index ba462729f09..3d8c3ad393f 100644 --- a/pkg/commands/git_commands/worktree_loader_test.go +++ b/pkg/commands/git_commands/worktree_loader_test.go @@ -190,11 +190,7 @@ branch refs/heads/mybranch-worktree } getRevParseArgs := func() []string { - args := []string{"rev-parse"} - if version.IsAtLeast(2, 31, 0) { - args = append(args, "--path-format=absolute") - } - return args + return []string{"rev-parse", "--path-format=absolute"} } s.before(runner, fs, getRevParseArgs) diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 5a725a677e5..cc3eb4fe6e4 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -1709,7 +1709,7 @@ func EnglishTranslationSet() *TranslationSet { CreateNewBranchFromCommit: "Create new branch off of commit", BuildingPatch: "Building patch", ViewCommits: "View commits", - MinGitVersionError: "Git version must be at least 2.22 (i.e. from 2019 onwards). Please upgrade your git version. Alternatively raise an issue at https://github.com/jesseduffield/lazygit/issues for lazygit to be more backwards compatible.", + MinGitVersionError: "Git version must be at least 2.32 (i.e. from 2021 onwards). Please upgrade your git version. Alternatively raise an issue at https://github.com/jesseduffield/lazygit/issues for lazygit to be more backwards compatible.", RunningCustomCommandStatus: "Running custom command", SubmoduleStashAndReset: "Stash uncommitted submodule changes and update", AndResetSubmodules: "And reset submodules", diff --git a/pkg/integration/tests/commit/create_amend_commit.go b/pkg/integration/tests/commit/create_amend_commit.go index 5777b2abb98..474e24099f0 100644 --- a/pkg/integration/tests/commit/create_amend_commit.go +++ b/pkg/integration/tests/commit/create_amend_commit.go @@ -41,20 +41,18 @@ var CreateAmendCommit = NewIntegrationTest(NewIntegrationTestArgs{ Contains("commit 01"), ) - if t.Git().Version().IsAtLeast(2, 32, 0) { // Support for auto-squashing "amend!" commits was added in git 2.32.0 - t.Views().Commits(). - Press(keys.Commits.SquashAboveCommits). - Tap(func() { - t.ExpectPopup().Menu(). - Title(Equals("Apply fixup commits")). - Select(Contains("Above the selected commit")). - Confirm() - }). - Lines( - Contains("commit 03"), - Contains("commit 02 amended").IsSelected(), - Contains("commit 01"), - ) - } + t.Views().Commits(). + Press(keys.Commits.SquashAboveCommits). + Tap(func() { + t.ExpectPopup().Menu(). + Title(Equals("Apply fixup commits")). + Select(Contains("Above the selected commit")). + Confirm() + }). + Lines( + Contains("commit 03"), + Contains("commit 02 amended").IsSelected(), + Contains("commit 01"), + ) }, }) diff --git a/pkg/integration/tests/config/negative_refspec.go b/pkg/integration/tests/config/negative_refspec.go index 0859722f49b..46148a713fe 100644 --- a/pkg/integration/tests/config/negative_refspec.go +++ b/pkg/integration/tests/config/negative_refspec.go @@ -8,7 +8,6 @@ import ( var NegativeRefspec = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Having a config with a negative refspec", ExtraCmdArgs: []string{}, - GitVersion: AtLeast("2.29.0"), SetupRepo: func(shell *Shell) { shell. SetConfig("remote.origin.fetch", "^refs/heads/test"). diff --git a/pkg/integration/tests/patch_building/move_to_earlier_commit.go b/pkg/integration/tests/patch_building/move_to_earlier_commit.go index c7916c0a686..0c5e60f3557 100644 --- a/pkg/integration/tests/patch_building/move_to_earlier_commit.go +++ b/pkg/integration/tests/patch_building/move_to_earlier_commit.go @@ -9,7 +9,6 @@ var MoveToEarlierCommit = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Move a patch from a commit to an earlier commit", ExtraCmdArgs: []string{}, Skip: false, - GitVersion: AtLeast("2.26.0"), SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateDir("dir") diff --git a/pkg/integration/tests/patch_building/move_to_earlier_commit_no_keep_empty.go b/pkg/integration/tests/patch_building/move_to_earlier_commit_no_keep_empty.go deleted file mode 100644 index e3a9003c004..00000000000 --- a/pkg/integration/tests/patch_building/move_to_earlier_commit_no_keep_empty.go +++ /dev/null @@ -1,78 +0,0 @@ -package patch_building - -import ( - "github.com/jesseduffield/lazygit/pkg/config" - . "github.com/jesseduffield/lazygit/pkg/integration/components" -) - -var MoveToEarlierCommitNoKeepEmpty = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Move a patch from a commit to an earlier commit, for older git versions that don't keep the empty commit", - ExtraCmdArgs: []string{}, - Skip: false, - GitVersion: Before("2.26.0"), - SetupConfig: func(config *config.AppConfig) {}, - SetupRepo: func(shell *Shell) { - shell.CreateDir("dir") - shell.CreateFileAndAdd("dir/file1", "file1 content") - shell.CreateFileAndAdd("dir/file2", "file2 content") - shell.Commit("first commit") - - shell.CreateFileAndAdd("unrelated-file", "") - shell.Commit("destination commit") - - shell.UpdateFileAndAdd("dir/file1", "file1 content with old changes") - shell.DeleteFileAndAdd("dir/file2") - shell.CreateFileAndAdd("dir/file3", "file3 content") - shell.Commit("commit to move from") - }, - Run: func(t *TestDriver, keys config.KeybindingConfig) { - t.Views().Commits(). - Focus(). - Lines( - Contains("commit to move from").IsSelected(), - Contains("destination commit"), - Contains("first commit"), - ). - PressEnter() - - t.Views().CommitFiles(). - IsFocused(). - Lines( - Contains("dir").IsSelected(), - Contains(" M file1"), - Contains(" D file2"), - Contains(" A file3"), - ). - PressPrimaryAction(). - PressEscape() - - t.Views().Information().Content(Contains("Building patch")) - - t.Views().Commits(). - IsFocused(). - SelectNextItem() - - t.Common().SelectPatchOption(Contains("Move patch to selected commit")) - - t.Views().Commits(). - IsFocused(). - Lines( - Contains("destination commit"), - Contains("first commit").IsSelected(), - ). - SelectPreviousItem(). - PressEnter() - - t.Views().CommitFiles(). - IsFocused(). - Lines( - Equals("▼ /").IsSelected(), - Equals(" ▼ dir"), - Equals(" M file1"), - Equals(" D file2"), - Equals(" A file3"), - Equals(" A unrelated-file"), - ). - PressEscape() - }, -}) diff --git a/pkg/integration/tests/patch_building/move_to_new_commit_before.go b/pkg/integration/tests/patch_building/move_to_new_commit_before.go index 79964519ec8..41e59d5b00b 100644 --- a/pkg/integration/tests/patch_building/move_to_new_commit_before.go +++ b/pkg/integration/tests/patch_building/move_to_new_commit_before.go @@ -9,7 +9,6 @@ var MoveToNewCommitBefore = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Move a patch from a commit to a new commit before the original one", ExtraCmdArgs: []string{}, Skip: false, - GitVersion: AtLeast("2.26.0"), SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.CreateDir("dir") diff --git a/pkg/integration/tests/patch_building/move_to_new_commit_before_no_keep_empty.go b/pkg/integration/tests/patch_building/move_to_new_commit_before_no_keep_empty.go deleted file mode 100644 index bf4e278ef54..00000000000 --- a/pkg/integration/tests/patch_building/move_to_new_commit_before_no_keep_empty.go +++ /dev/null @@ -1,77 +0,0 @@ -package patch_building - -import ( - "github.com/jesseduffield/lazygit/pkg/config" - . "github.com/jesseduffield/lazygit/pkg/integration/components" -) - -var MoveToNewCommitBeforeNoKeepEmpty = NewIntegrationTest(NewIntegrationTestArgs{ - Description: "Move a patch from a commit to a new commit before the original one, for older git versions that don't keep the empty commit", - ExtraCmdArgs: []string{}, - Skip: false, - GitVersion: Before("2.26.0"), - SetupConfig: func(config *config.AppConfig) {}, - SetupRepo: func(shell *Shell) { - shell.CreateDir("dir") - shell.CreateFileAndAdd("dir/file1", "file1 content") - shell.CreateFileAndAdd("dir/file2", "file2 content") - shell.Commit("first commit") - - shell.UpdateFileAndAdd("dir/file1", "file1 content with old changes") - shell.DeleteFileAndAdd("dir/file2") - shell.CreateFileAndAdd("dir/file3", "file3 content") - shell.Commit("commit to move from") - - shell.UpdateFileAndAdd("dir/file1", "file1 content with new changes") - shell.Commit("third commit") - }, - Run: func(t *TestDriver, keys config.KeybindingConfig) { - t.Views().Commits(). - Focus(). - Lines( - Contains("third commit").IsSelected(), - Contains("commit to move from"), - Contains("first commit"), - ). - SelectNextItem(). - PressEnter() - - t.Views().CommitFiles(). - IsFocused(). - Lines( - Contains("dir").IsSelected(), - Contains(" M file1"), - Contains(" D file2"), - Contains(" A file3"), - ). - PressPrimaryAction(). - PressEscape() - - t.Views().Information().Content(Contains("Building patch")) - - t.Common().SelectPatchOption(Contains("Move patch into new commit before the original commit")) - - t.ExpectPopup().CommitMessagePanel(). - InitialText(Equals("")). - Type("new commit").Confirm() - - t.Views().Commits(). - IsFocused(). - Lines( - Contains("third commit"), - Contains("new commit").IsSelected(), - Contains("first commit"), - ). - PressEnter() - - t.Views().CommitFiles(). - IsFocused(). - Lines( - Contains("dir").IsSelected(), - Contains(" M file1"), - Contains(" D file2"), - Contains(" A file3"), - ). - PressEscape() - }, -}) diff --git a/pkg/integration/tests/sync/force_push_triangular.go b/pkg/integration/tests/sync/force_push_triangular.go index 70912d1232c..af965c23e81 100644 --- a/pkg/integration/tests/sync/force_push_triangular.go +++ b/pkg/integration/tests/sync/force_push_triangular.go @@ -9,7 +9,6 @@ var ForcePushTriangular = NewIntegrationTest(NewIntegrationTestArgs{ Description: "Push to a remote, requiring a force push because the branch is behind the remote push branch but not the upstream", ExtraCmdArgs: []string{}, Skip: false, - GitVersion: AtLeast("2.22.0"), SetupConfig: func(config *config.AppConfig) {}, SetupRepo: func(shell *Shell) { shell.SetConfig("push.default", "current") diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index fa5aff628ec..9de69d3b0a4 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -306,7 +306,6 @@ var tests = []*components.IntegrationTest{ patch_building.MoveRangeToIndex, patch_building.MoveToEarlierCommit, patch_building.MoveToEarlierCommitFromAddedFile, - patch_building.MoveToEarlierCommitNoKeepEmpty, patch_building.MoveToIndex, patch_building.MoveToIndexFromAddedFileWithConflict, patch_building.MoveToIndexPartOfAdjacentAddedLines, @@ -318,7 +317,6 @@ var tests = []*components.IntegrationTest{ patch_building.MoveToLaterCommitPartialHunk, patch_building.MoveToNewCommit, patch_building.MoveToNewCommitBefore, - patch_building.MoveToNewCommitBeforeNoKeepEmpty, patch_building.MoveToNewCommitFromAddedFile, patch_building.MoveToNewCommitFromDeletedFile, patch_building.MoveToNewCommitInLastCommitOfStackedBranch,