mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-11-28 09:08:41 +02:00
Add a method GitVersion.IsAtLeast
This commit is contained in:
parent
b657fc4f0b
commit
6255728e63
@ -221,9 +221,9 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(opts PrepareInteract
|
||||
Arg("--interactive").
|
||||
Arg("--autostash").
|
||||
Arg("--keep-empty").
|
||||
ArgIf(opts.keepCommitsThatBecomeEmpty && !self.version.IsOlderThan(2, 26, 0), "--empty=keep").
|
||||
ArgIf(opts.keepCommitsThatBecomeEmpty && self.version.IsAtLeast(2, 26, 0), "--empty=keep").
|
||||
Arg("--no-autosquash").
|
||||
ArgIf(!self.version.IsOlderThan(2, 22, 0), "--rebase-merges").
|
||||
ArgIf(self.version.IsAtLeast(2, 22, 0), "--rebase-merges").
|
||||
ArgIf(opts.onto != "", "--onto", opts.onto).
|
||||
Arg(opts.baseShaOrRoot).
|
||||
ToArgv()
|
||||
|
@ -69,3 +69,11 @@ func (v *GitVersion) IsOlderThan(major, minor, patch int) bool {
|
||||
func (v *GitVersion) IsOlderThanVersion(version *GitVersion) bool {
|
||||
return v.IsOlderThan(version.Major, version.Minor, version.Patch)
|
||||
}
|
||||
|
||||
func (v *GitVersion) IsAtLeast(major, minor, patch int) bool {
|
||||
return !v.IsOlderThan(major, minor, patch)
|
||||
}
|
||||
|
||||
func (v *GitVersion) IsAtLeastVersion(version *GitVersion) bool {
|
||||
return v.IsAtLeast(version.Major, version.Minor, version.Patch)
|
||||
}
|
||||
|
@ -45,3 +45,12 @@ func TestGitVersionIsOlderThan(t *testing.T) {
|
||||
assert.True(t, (&GitVersion{2, 0, 1, ""}).IsOlderThan(2, 1, 0))
|
||||
assert.True(t, (&GitVersion{2, 0, 1, ""}).IsOlderThan(3, 0, 0))
|
||||
}
|
||||
|
||||
func TestGitVersionIsAtLeast(t *testing.T) {
|
||||
assert.True(t, (&GitVersion{2, 0, 0, ""}).IsAtLeast(1, 99, 99))
|
||||
assert.True(t, (&GitVersion{2, 0, 0, ""}).IsAtLeast(2, 0, 0))
|
||||
assert.True(t, (&GitVersion{2, 1, 0, ""}).IsAtLeast(2, 0, 9))
|
||||
|
||||
assert.False(t, (&GitVersion{2, 0, 1, ""}).IsAtLeast(2, 1, 0))
|
||||
assert.False(t, (&GitVersion{2, 0, 1, ""}).IsAtLeast(3, 0, 0))
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ func (self GitVersionRestriction) shouldRunOnVersion(version *git_commands.GitVe
|
||||
if err != nil {
|
||||
panic("Invalid git version string: " + self.from)
|
||||
}
|
||||
return !version.IsOlderThanVersion(from)
|
||||
return version.IsAtLeastVersion(from)
|
||||
}
|
||||
if self.before != "" {
|
||||
before, err := git_commands.ParseGitVersion(self.before)
|
||||
|
Loading…
Reference in New Issue
Block a user