mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-11-30 09:16:47 +02:00
Allow interactive rebasing all the way down to the first commit
Pass --root instead of a sha when we want to rebase down to the initial commit.
This commit is contained in:
parent
dd61c49a15
commit
a349e886ce
@ -130,7 +130,7 @@ func (self *RebaseCommands) InteractiveRebaseBreakAfter(commits []*models.Commit
|
||||
// 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
|
||||
func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseSha string, todoLines []TodoLine, overrideEditor bool) oscommands.ICmdObj {
|
||||
func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseShaOrRoot string, todoLines []TodoLine, overrideEditor bool) oscommands.ICmdObj {
|
||||
todo := self.buildTodo(todoLines)
|
||||
ex := oscommands.GetLazygitPath()
|
||||
|
||||
@ -139,7 +139,7 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseSha string, todo
|
||||
debug = "TRUE"
|
||||
}
|
||||
|
||||
cmdStr := fmt.Sprintf("git rebase --interactive --autostash --keep-empty --no-autosquash %s", baseSha)
|
||||
cmdStr := fmt.Sprintf("git rebase --interactive --autostash --keep-empty --no-autosquash %s", baseShaOrRoot)
|
||||
self.Log.WithField("command", cmdStr).Debug("RunCommand")
|
||||
|
||||
cmdObj := self.cmd.New(cmdStr)
|
||||
@ -172,10 +172,6 @@ func (self *RebaseCommands) PrepareInteractiveRebaseCommand(baseSha string, todo
|
||||
func (self *RebaseCommands) BuildSingleActionTodo(commits []*models.Commit, actionIndex int, action string) ([]TodoLine, string, error) {
|
||||
baseIndex := actionIndex + 1
|
||||
|
||||
if len(commits) <= baseIndex {
|
||||
return nil, "", errors.New(self.Tr.CannotRebaseOntoFirstCommit)
|
||||
}
|
||||
|
||||
if action == "squash" || action == "fixup" {
|
||||
baseIndex++
|
||||
}
|
||||
@ -193,7 +189,12 @@ func (self *RebaseCommands) BuildSingleActionTodo(commits []*models.Commit, acti
|
||||
}
|
||||
})
|
||||
|
||||
return todoLines, commits[baseIndex].Sha, nil
|
||||
baseSha := "--root"
|
||||
if baseIndex < len(commits) {
|
||||
baseSha = commits[baseIndex].Sha
|
||||
}
|
||||
|
||||
return todoLines, baseSha, nil
|
||||
}
|
||||
|
||||
// AmendTo amends the given commit with whatever files are staged
|
||||
|
@ -216,7 +216,6 @@ func chineseTranslationSet() TranslationSet {
|
||||
LcPasteCommits: "粘贴提交(拣选)",
|
||||
SureCherryPick: "您确定要将选中的提交进行拣选到这个分支吗?",
|
||||
CherryPick: "拣选 (Cherry-Pick)",
|
||||
CannotRebaseOntoFirstCommit: "您不能以交互方式变基 (rebase) 至第一次提交",
|
||||
Donate: "捐助",
|
||||
AskQuestion: "提问咨询",
|
||||
PrevLine: "选择上一行",
|
||||
|
@ -181,7 +181,6 @@ func dutchTranslationSet() TranslationSet {
|
||||
LcPasteCommits: "plak commits (cherry-pick)",
|
||||
SureCherryPick: "Weet je zeker dat je de gekopieerde commits naar deze branch wil cherry-picken?",
|
||||
CherryPick: "Cherry-Pick",
|
||||
CannotRebaseOntoFirstCommit: "Je kan niet interactief rebasen naar de eerste commit",
|
||||
Donate: "Doneer",
|
||||
PrevLine: "selecteer de vorige lijn",
|
||||
NextLine: "selecteer de volgende lijn",
|
||||
|
@ -219,7 +219,6 @@ type TranslationSet struct {
|
||||
LcPasteCommits string
|
||||
SureCherryPick string
|
||||
CherryPick string
|
||||
CannotRebaseOntoFirstCommit string
|
||||
Donate string
|
||||
AskQuestion string
|
||||
PrevLine string
|
||||
@ -868,7 +867,6 @@ func EnglishTranslationSet() TranslationSet {
|
||||
LcPasteCommits: "paste commits (cherry-pick)",
|
||||
SureCherryPick: "Are you sure you want to cherry-pick the copied commits onto this branch?",
|
||||
CherryPick: "Cherry-Pick",
|
||||
CannotRebaseOntoFirstCommit: "You cannot interactive rebase onto the first commit",
|
||||
Donate: "Donate",
|
||||
AskQuestion: "Ask Question",
|
||||
PrevLine: "select previous line",
|
||||
|
@ -216,7 +216,6 @@ func japaneseTranslationSet() TranslationSet {
|
||||
LcPasteCommits: "コミットを貼り付け (cherry-pick)",
|
||||
// SureCherryPick: "Are you sure you want to cherry-pick the copied commits onto this branch?",
|
||||
CherryPick: "Cherry-Pick",
|
||||
// CannotRebaseOntoFirstCommit: "You cannot interactive rebase onto the first commit",
|
||||
Donate: "支援",
|
||||
AskQuestion: "質問",
|
||||
PrevLine: "前の行を選択",
|
||||
|
@ -217,7 +217,6 @@ func koreanTranslationSet() TranslationSet {
|
||||
LcPasteCommits: "커밋을 붙여넣기 (cherry-pick)",
|
||||
SureCherryPick: "정말로 복사한 커밋을 이 브랜치에 체리픽하시겠습니까?",
|
||||
CherryPick: "체리픽",
|
||||
CannotRebaseOntoFirstCommit: "첫 번째 커밋에 대해 대화식으로 리베이스할 수 없습니다.",
|
||||
Donate: "후원",
|
||||
AskQuestion: "질문하기",
|
||||
PrevLine: "이전 줄 선택",
|
||||
|
@ -149,7 +149,6 @@ func polishTranslationSet() TranslationSet {
|
||||
LcPasteCommits: "wklej commity (przebieranie)",
|
||||
SureCherryPick: "Czy na pewno chcesz przebierać w skopiowanych commitach na tej gałęzi?",
|
||||
CherryPick: "Przebieranie",
|
||||
CannotRebaseOntoFirstCommit: "Nie można interaktywnie zmienić bazy na pierwszym commicie",
|
||||
Donate: "Wesprzyj",
|
||||
PrevLine: "poprzednia linia",
|
||||
NextLine: "następna linia",
|
||||
|
Loading…
Reference in New Issue
Block a user