Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (app *App) validateGitVersion() (*git_commands.GitVersion, error) {
return nil, minVersionError
}

if version.IsOlderThan(2, 0, 0) {
if version.IsOlderThan(2, 20, 0) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jesseduffield Not sure you'll agree with this. Personally I find it a bit insane to support nine-year-old git versions, so I'd have no problem with this change; but if you object, I think it should be possible to fall back to the old way of editing a commit if the git version is older than 2.20. Let me know what you prefer.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with it. 2.0 was arbitrary in the first place

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, great. I added a commit to revert a compatibility fix that was added for supporting versions older than 2.7, which we now no longer need; @Ryooooooga, please have a look.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return nil, minVersionError
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 15 additions & 1 deletion pkg/commands/git_commands/rebase.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,16 @@ func (self *RebaseCommands) InteractiveRebase(commits []*models.Commit, index in
return self.PrepareInteractiveRebaseCommand(sha, todo, true).Run()
}

func (self *RebaseCommands) InteractiveRebaseBreakAfter(commits []*models.Commit, index int) error {
todo, sha, err := self.BuildSingleActionTodo(commits, index-1, "pick")
if err != nil {
return err
}

todo = append(todo, TodoLine{Action: "break", Commit: nil})
return self.PrepareInteractiveRebaseCommand(sha, todo, true).Run()
}

// PrepareInteractiveRebaseCommand returns the cmd for an interactive rebase
// we tell git to run lazygit to edit the todo list, and we pass the client
// lazygit a todo string to write to the todo file
Expand Down Expand Up @@ -400,5 +410,9 @@ type TodoLine struct {
}

func (self *TodoLine) ToString() string {
return self.Action + " " + self.Commit.Sha + " " + self.Commit.Name + "\n"
if self.Action == "break" {
return self.Action + "\n"
} else {
return self.Action + " " + self.Commit.Sha + " " + self.Commit.Name + "\n"
}
}
18 changes: 4 additions & 14 deletions pkg/commands/git_commands/tag_loader.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
}
Expand Down
39 changes: 6 additions & 33 deletions pkg/commands/git_commands/tag_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,21 @@ testtag
func TestGetTags(t *testing.T) {
type scenario struct {
testName string
gitVersion *GitVersion
runner *oscommands.FakeCmdObjRunner
expectedTags []*models.Tag
expectedError error
}

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{
Expand All @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion pkg/gui/controllers/local_commits_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,8 @@ func (self *LocalCommitsController) edit(commit *models.Commit) error {

return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func() error {
self.c.LogAction(self.c.Tr.Actions.EditCommit)
return self.interactiveRebase("edit")
err := self.git.Rebase.InteractiveRebaseBreakAfter(self.model.Commits, self.context().GetSelectedLineIdx())
return self.helpers.MergeAndRebase.CheckMergeOrRebase(err)
})
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/i18n/chinese.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ func chineseTranslationSet() TranslationSet {
LcCreateNewBranchFromCommit: "从提交创建新分支",
LcBuildingPatch: "正在构建补丁",
LcViewCommits: "查看提交",
MinGitVersionError: "Git 版本必须至少为 2.0(即从 2014 年开始的版本)。请更新 git。或者在 https://github.com/jesseduffield/lazygit/issues 上提出一个问题,以使 lazygit 更加向后兼容。",
MinGitVersionError: "Git 版本必须至少为 2.20(即从 2018 年开始的版本)。请更新 git。或者在 https://github.com/jesseduffield/lazygit/issues 上提出一个问题,以使 lazygit 更加向后兼容。",
LcRunningCustomCommandStatus: "正在运行自定义命令",
LcSubmoduleStashAndReset: "存放未提交的子模块更改和更新",
LcAndResetSubmodules: "和重置子模块",
Expand Down
2 changes: 1 addition & 1 deletion pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,7 @@ func EnglishTranslationSet() TranslationSet {
LcCreateNewBranchFromCommit: "create new branch off of commit",
LcBuildingPatch: "building patch",
LcViewCommits: "view commits",
MinGitVersionError: "Git version must be at least 2.0 (i.e. from 2014 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.20 (i.e. from 2018 onwards). Please upgrade your git version. Alternatively raise an issue at https://github.com/jesseduffield/lazygit/issues for lazygit to be more backwards compatible.",
LcRunningCustomCommandStatus: "running custom command",
LcSubmoduleStashAndReset: "stash uncommitted submodule changes and update",
LcAndResetSubmodules: "and reset submodules",
Expand Down
2 changes: 1 addition & 1 deletion pkg/i18n/japanese.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func japaneseTranslationSet() TranslationSet {
LcCreateNewBranchFromCommit: "コミットにブランチを作成",
LcBuildingPatch: "パッチを構築",
LcViewCommits: "コミットを閲覧",
MinGitVersionError: "lazygitの実行にはGit 2.0以降のバージョンが必要です。Gitを更新してください。もしくは、lazygitの後方互換性を改善するために https://github.com/jesseduffield/lazygit/issues にissueを作成してください。",
MinGitVersionError: "lazygitの実行にはGit 2.20以降のバージョンが必要です。Gitを更新してください。もしくは、lazygitの後方互換性を改善するために https://github.com/jesseduffield/lazygit/issues にissueを作成してください。",
LcRunningCustomCommandStatus: "カスタムコマンドを実行",
// LcSubmoduleStashAndReset: "stash uncommitted submodule changes and update",
// LcAndResetSubmodules: "and reset submodules",
Expand Down
2 changes: 1 addition & 1 deletion pkg/i18n/korean.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ func koreanTranslationSet() TranslationSet {
LcCreateNewBranchFromCommit: "커밋에서 새 브랜치를 만듭니다.",
LcBuildingPatch: "building patch",
LcViewCommits: "커밋 보기",
MinGitVersionError: "lazygit 실행을 위해서는 Git 2.0 이후의 버전(2014년 이후의)이 필요합니다. Git를 업데이트 해주세요. 아니면 lazygit이 이전 버전과 더 잘 호환되도록 https://github.com/jesseduffield/lazygit/issues 에 issue를 작성해 주세요.",
MinGitVersionError: "lazygit 실행을 위해서는 Git 2.20 이후의 버전(2018년 이후의)이 필요합니다. Git를 업데이트 해주세요. 아니면 lazygit이 이전 버전과 더 잘 호환되도록 https://github.com/jesseduffield/lazygit/issues 에 issue를 작성해 주세요.",
LcRunningCustomCommandStatus: "커스텀 명령어 실행",
LcSubmoduleStashAndReset: "stash uncommitted submodule changes and update",
LcAndResetSubmodules: "and reset submodules",
Expand Down