diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-02-19 11:36:06 +0100 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2023-02-19 16:13:31 +0100 |
commit | ac9515d8c77dab0da87d913db6c2bdec3be6fe3c (patch) | |
tree | fdce23e9f5a0575bd4c5651e0338dfcb23390413 | |
parent | 67b8ef449cf13ad7ac6dc52829331ad9803fefff (diff) |
Revert "fix: improve backward compatibility"
Since we now require git 2.20, we don't need this any more.
This reverts commit 7c5f33980f541472aa29e4e072ace63358983308.
-rw-r--r-- | pkg/commands/git.go | 2 | ||||
-rw-r--r-- | pkg/commands/git_commands/tag_loader.go | 18 | ||||
-rw-r--r-- | pkg/commands/git_commands/tag_loader_test.go | 39 |
3 files changed, 11 insertions, 48 deletions
diff --git a/pkg/commands/git.go b/pkg/commands/git.go index e2a31c009..35cead260 100644 --- a/pkg/commands/git.go +++ b/pkg/commands/git.go @@ -133,7 +133,7 @@ func NewGitCommandAux( reflogCommitLoader := git_commands.NewReflogCommitLoader(cmn, cmd) remoteLoader := git_commands.NewRemoteLoader(cmn, cmd, repo.Remotes) stashLoader := git_commands.NewStashLoader(cmn, cmd) - tagLoader := git_commands.NewTagLoader(cmn, version, cmd) + tagLoader := git_commands.NewTagLoader(cmn, cmd) return &GitCommand{ Branch: branchCommands, diff --git a/pkg/commands/git_commands/tag_loader.go b/pkg/commands/git_commands/tag_loader.go index f9674a2b0..738283405 100644 --- a/pkg/commands/git_commands/tag_loader.go +++ b/pkg/commands/git_commands/tag_loader.go @@ -1,8 +1,6 @@ package git_commands import ( - "fmt" - "github.com/jesseduffield/generics/slices" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/commands/oscommands" @@ -12,31 +10,23 @@ import ( type TagLoader struct { *common.Common - version *GitVersion - cmd oscommands.ICmdObjBuilder + cmd oscommands.ICmdObjBuilder } func NewTagLoader( common *common.Common, - version *GitVersion, cmd oscommands.ICmdObjBuilder, ) *TagLoader { return &TagLoader{ - Common: common, - version: version, - cmd: cmd, + Common: common, + cmd: cmd, } } func (self *TagLoader) GetTags() ([]*models.Tag, error) { // get remote branches, sorted by creation date (descending) // see: https://git-scm.com/docs/git-tag#Documentation/git-tag.txt---sortltkeygt - sortKey := "-creatordate" - if self.version.IsOlderThan(2, 7, 0) { - sortKey = "-v:refname" - } - - tagsOutput, err := self.cmd.New(fmt.Sprintf(`git tag --list --sort=%s`, sortKey)).DontLog().RunWithOutput() + tagsOutput, err := self.cmd.New(`git tag --list --sort=-creatordate`).DontLog().RunWithOutput() if err != nil { return nil, err } diff --git a/pkg/commands/git_commands/tag_loader_test.go b/pkg/commands/git_commands/tag_loader_test.go index 287d6e3c6..f8696cafa 100644 --- a/pkg/commands/git_commands/tag_loader_test.go +++ b/pkg/commands/git_commands/tag_loader_test.go @@ -20,7 +20,6 @@ testtag func TestGetTags(t *testing.T) { type scenario struct { testName string - gitVersion *GitVersion runner *oscommands.FakeCmdObjRunner expectedTags []*models.Tag expectedError error @@ -28,24 +27,14 @@ func TestGetTags(t *testing.T) { scenarios := []scenario{ { - testName: "should return no tags if there are none", - gitVersion: &GitVersion{2, 7, 0, ""}, + testName: "should return no tags if there are none", runner: oscommands.NewFakeRunner(t). Expect(`git tag --list --sort=-creatordate`, "", nil), expectedTags: []*models.Tag{}, expectedError: nil, }, { - testName: "should return no tags if there are none (< 2.7.0)", - gitVersion: &GitVersion{2, 6, 7, ""}, - runner: oscommands.NewFakeRunner(t). - Expect(`git tag --list --sort=-v:refname`, "", nil), - expectedTags: []*models.Tag{}, - expectedError: nil, - }, - { - testName: "should return tags if present", - gitVersion: &GitVersion{2, 7, 0, ""}, + testName: "should return tags if present", runner: oscommands.NewFakeRunner(t). Expect(`git tag --list --sort=-creatordate`, tagsOutput, nil), expectedTags: []*models.Tag{ @@ -58,31 +47,15 @@ func TestGetTags(t *testing.T) { }, expectedError: nil, }, - { - testName: "should return tags if present (< 2.7.0)", - gitVersion: &GitVersion{2, 6, 7, ""}, - runner: oscommands.NewFakeRunner(t). - Expect(`git tag --list --sort=-v:refname`, tagsOutput, nil), - expectedTags: []*models.Tag{ - {Name: "v0.34"}, - {Name: "v0.33"}, - {Name: "v0.32.2"}, - {Name: "v0.32.1"}, - {Name: "v0.32"}, - {Name: "testtag"}, - }, - expectedError: nil, - }, } for _, scenario := range scenarios { scenario := scenario t.Run(scenario.testName, func(t *testing.T) { - loader := NewTagLoader( - utils.NewDummyCommon(), - scenario.gitVersion, - oscommands.NewDummyCmdObjBuilder(scenario.runner), - ) + loader := &TagLoader{ + Common: utils.NewDummyCommon(), + cmd: oscommands.NewDummyCmdObjBuilder(scenario.runner), + } tags, err := loader.GetTags() |