1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-15 11:56:37 +02:00

feat: allow to perform a rebase with breaking before the first commit

This commit is contained in:
AzraelSec 2023-03-29 00:53:14 +02:00 committed by Jesse Duffield
parent 368f9c8cb3
commit a3fdf91714
7 changed files with 40 additions and 22 deletions

View File

@ -126,6 +126,11 @@ func (self *RebaseCommands) InteractiveRebaseBreakAfter(commits []*models.Commit
return self.PrepareInteractiveRebaseCommand(sha, todo, true, false).Run() return self.PrepareInteractiveRebaseCommand(sha, todo, true, false).Run()
} }
func (self *RebaseCommands) EditRebase(branchRef string) error {
commands := []TodoLine{{Action: "break"}}
return self.PrepareInteractiveRebaseCommand(branchRef, commands, false, true).Run()
}
// PrepareInteractiveRebaseCommand returns the cmd for an interactive rebase // PrepareInteractiveRebaseCommand returns the cmd for an interactive rebase
// we tell git to run lazygit to edit the todo list, and we pass the client // 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 // lazygit a todo string to write to the todo file

View File

@ -201,22 +201,39 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error {
if ref == checkedOutBranch { if ref == checkedOutBranch {
return self.c.ErrorMsg(self.c.Tr.CantRebaseOntoSelf) return self.c.ErrorMsg(self.c.Tr.CantRebaseOntoSelf)
} }
prompt := utils.ResolvePlaceholderString( menuItems := []*types.MenuItem{
self.c.Tr.ConfirmRebase, {
Label: self.c.Tr.SimpleRebase,
Key: 's',
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.RebaseBranch)
err := self.git.Rebase.RebaseBranch(ref)
return self.CheckMergeOrRebase(err)
},
},
{
Label: self.c.Tr.InteractiveRebase,
Key: 'i',
Tooltip: self.c.Tr.InteractiveRebaseTooltip,
OnPress: func() error {
self.c.LogAction(self.c.Tr.Actions.RebaseBranch)
err := self.git.Rebase.EditRebase(ref)
return self.CheckMergeOrRebase(err)
},
},
}
title := utils.ResolvePlaceholderString(
self.c.Tr.RebasingTitle,
map[string]string{ map[string]string{
"checkedOutBranch": checkedOutBranch, "checkedOutBranch": checkedOutBranch,
"selectedBranch": ref, "ref": ref,
}, },
) )
return self.c.Confirm(types.ConfirmOpts{ return self.c.Menu(types.CreateMenuOptions{
Title: self.c.Tr.RebasingTitle, Title: title,
Prompt: prompt, Items: menuItems,
HandleConfirm: func() error {
self.c.LogAction(self.c.Tr.Actions.RebaseBranch)
err := self.git.Rebase.RebaseBranch(ref)
return self.CheckMergeOrRebase(err)
},
}) })
} }

View File

@ -201,8 +201,6 @@ func chineseTranslationSet() TranslationSet {
ReflogCommitsTitle: "Reflog 页面", ReflogCommitsTitle: "Reflog 页面",
GlobalTitle: "全局键绑定", GlobalTitle: "全局键绑定",
ConflictsResolved: "已解决所有冲突。是否继续?", ConflictsResolved: "已解决所有冲突。是否继续?",
RebasingTitle: "变基",
ConfirmRebase: "您确定要将分支 {{.checkedOutBranch}} 变基到 {{.selectedBranch}} 吗?",
ConfirmMerge: "您确定要将分支 {{.selectedBranch}} 合并到 {{.checkedOutBranch}} 吗?", ConfirmMerge: "您确定要将分支 {{.selectedBranch}} 合并到 {{.checkedOutBranch}} 吗?",
FwdNoUpstream: "此分支没有上游,无法快进", FwdNoUpstream: "此分支没有上游,无法快进",
FwdNoLocalUpstream: "此分支的远程未在本地注册,无法快进", FwdNoLocalUpstream: "此分支的远程未在本地注册,无法快进",

View File

@ -166,9 +166,7 @@ func dutchTranslationSet() TranslationSet {
ReflogCommitsTitle: "Reflog", ReflogCommitsTitle: "Reflog",
GlobalTitle: "Globale Sneltoetsen", GlobalTitle: "Globale Sneltoetsen",
ConflictsResolved: "alle merge conflicten zijn opgelost. Wilt je verder gaan?", ConflictsResolved: "alle merge conflicten zijn opgelost. Wilt je verder gaan?",
RebasingTitle: "Rebasen",
MergingTitle: "Mergen", MergingTitle: "Mergen",
ConfirmRebase: "Weet je zeker dat je '{{.checkedOutBranch}}' op '{{.selectedBranch}}' wil rebasen?",
ConfirmMerge: "Weet je zeker dat je '{{.selectedBranch}}' in '{{.checkedOutBranch}}' wil mergen?", ConfirmMerge: "Weet je zeker dat je '{{.selectedBranch}}' in '{{.checkedOutBranch}}' wil mergen?",
FwdNoUpstream: "Kan niet de branch vooruitspoelen zonder upstream", FwdNoUpstream: "Kan niet de branch vooruitspoelen zonder upstream",
FwdCommitsToPush: "Je kan niet vooruitspoelen als de branch geen nieuwe commits heeft", FwdCommitsToPush: "Je kan niet vooruitspoelen als de branch geen nieuwe commits heeft",

View File

@ -209,7 +209,9 @@ type TranslationSet struct {
ReflogCommitsTitle string ReflogCommitsTitle string
ConflictsResolved string ConflictsResolved string
RebasingTitle string RebasingTitle string
ConfirmRebase string SimpleRebase string
InteractiveRebase string
InteractiveRebaseTooltip string
ConfirmMerge string ConfirmMerge string
FwdNoUpstream string FwdNoUpstream string
FwdNoLocalUpstream string FwdNoLocalUpstream string
@ -877,8 +879,10 @@ func EnglishTranslationSet() TranslationSet {
ReflogCommitsTitle: "Reflog", ReflogCommitsTitle: "Reflog",
GlobalTitle: "Global Keybindings", GlobalTitle: "Global Keybindings",
ConflictsResolved: "all merge conflicts resolved. Continue?", ConflictsResolved: "all merge conflicts resolved. Continue?",
RebasingTitle: "Rebasing", RebasingTitle: "Rebase '{{.checkedOutBranch}}' onto '{{.ref}}'",
ConfirmRebase: "Are you sure you want to rebase '{{.checkedOutBranch}}' on top of '{{.selectedBranch}}'?", SimpleRebase: "Simple rebase",
InteractiveRebase: "Interactive rebase",
InteractiveRebaseTooltip: "Begin an interactive rebase with a break at the start, so you can update the TODO commits before continuing",
ConfirmMerge: "Are you sure you want to merge '{{.selectedBranch}}' into '{{.checkedOutBranch}}'?", ConfirmMerge: "Are you sure you want to merge '{{.selectedBranch}}' into '{{.checkedOutBranch}}'?",
FwdNoUpstream: "Cannot fast-forward a branch with no upstream", FwdNoUpstream: "Cannot fast-forward a branch with no upstream",
FwdNoLocalUpstream: "Cannot fast-forward a branch whose remote is not registered locally", FwdNoLocalUpstream: "Cannot fast-forward a branch whose remote is not registered locally",

View File

@ -202,8 +202,6 @@ func koreanTranslationSet() TranslationSet {
ReflogCommitsTitle: "Reflog", ReflogCommitsTitle: "Reflog",
GlobalTitle: "글로벌 키 바인딩", GlobalTitle: "글로벌 키 바인딩",
ConflictsResolved: "모든 병합 충돌이 해결되었습니다. 계속 할까요?", ConflictsResolved: "모든 병합 충돌이 해결되었습니다. 계속 할까요?",
RebasingTitle: "리베이스 중",
ConfirmRebase: "정말로 '{{.checkedOutBranch}}' 을(를) '{{.selectedBranch}}'에 리베이스 하시겠습니까?",
ConfirmMerge: "정말로 '{{.selectedBranch}}' 을(를) '{{.checkedOutBranch}}'에 병합하시겠습니까?", ConfirmMerge: "정말로 '{{.selectedBranch}}' 을(를) '{{.checkedOutBranch}}'에 병합하시겠습니까?",
FwdNoUpstream: "Cannot fast-forward a branch with no upstream", FwdNoUpstream: "Cannot fast-forward a branch with no upstream",
FwdNoLocalUpstream: "Cannot fast-forward a branch whose remote is not registered locally", FwdNoLocalUpstream: "Cannot fast-forward a branch whose remote is not registered locally",

View File

@ -112,9 +112,7 @@ func polishTranslationSet() TranslationSet {
FileStagingRequirements: "Można tylko zatwierdzić pojedyncze linie dla śledzonych plików z niezatwierdzonymi zmianami", FileStagingRequirements: "Można tylko zatwierdzić pojedyncze linie dla śledzonych plików z niezatwierdzonymi zmianami",
StagingTitle: "Poczekalnia", StagingTitle: "Poczekalnia",
ReturnToFilesPanel: "wróć do panelu plików", ReturnToFilesPanel: "wróć do panelu plików",
RebasingTitle: "Zmiana bazy",
MergingTitle: "Scalanie", MergingTitle: "Scalanie",
ConfirmRebase: "Czy napewno chcesz zmienić bazę '{{.checkedOutBranch}}' na '{{.selectedBranch}}'?",
ConfirmMerge: "Czy na pewno chcesz scalić '{{.selectedBranch}}' do '{{.checkedOutBranch}}'?", ConfirmMerge: "Czy na pewno chcesz scalić '{{.selectedBranch}}' do '{{.checkedOutBranch}}'?",
FwdNoUpstream: "Nie można przewinąć gałęzi bez gałęzi nadrzędnej", FwdNoUpstream: "Nie można przewinąć gałęzi bez gałęzi nadrzędnej",
FwdCommitsToPush: "Nie można przewinąć gałęzi z commitami do wysłania", FwdCommitsToPush: "Nie można przewinąć gałęzi z commitami do wysłania",