1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-04 10:34:55 +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()
}
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
// 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

View File

@ -201,22 +201,39 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error {
if ref == checkedOutBranch {
return self.c.ErrorMsg(self.c.Tr.CantRebaseOntoSelf)
}
prompt := utils.ResolvePlaceholderString(
self.c.Tr.ConfirmRebase,
menuItems := []*types.MenuItem{
{
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{
"checkedOutBranch": checkedOutBranch,
"selectedBranch": ref,
"ref": ref,
},
)
return self.c.Confirm(types.ConfirmOpts{
Title: self.c.Tr.RebasingTitle,
Prompt: prompt,
HandleConfirm: func() error {
self.c.LogAction(self.c.Tr.Actions.RebaseBranch)
err := self.git.Rebase.RebaseBranch(ref)
return self.CheckMergeOrRebase(err)
},
return self.c.Menu(types.CreateMenuOptions{
Title: title,
Items: menuItems,
})
}

View File

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

View File

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

View File

@ -209,7 +209,9 @@ type TranslationSet struct {
ReflogCommitsTitle string
ConflictsResolved string
RebasingTitle string
ConfirmRebase string
SimpleRebase string
InteractiveRebase string
InteractiveRebaseTooltip string
ConfirmMerge string
FwdNoUpstream string
FwdNoLocalUpstream string
@ -877,8 +879,10 @@ func EnglishTranslationSet() TranslationSet {
ReflogCommitsTitle: "Reflog",
GlobalTitle: "Global Keybindings",
ConflictsResolved: "all merge conflicts resolved. Continue?",
RebasingTitle: "Rebasing",
ConfirmRebase: "Are you sure you want to rebase '{{.checkedOutBranch}}' on top of '{{.selectedBranch}}'?",
RebasingTitle: "Rebase '{{.checkedOutBranch}}' onto '{{.ref}}'",
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}}'?",
FwdNoUpstream: "Cannot fast-forward a branch with no upstream",
FwdNoLocalUpstream: "Cannot fast-forward a branch whose remote is not registered locally",

View File

@ -202,8 +202,6 @@ func koreanTranslationSet() TranslationSet {
ReflogCommitsTitle: "Reflog",
GlobalTitle: "글로벌 키 바인딩",
ConflictsResolved: "모든 병합 충돌이 해결되었습니다. 계속 할까요?",
RebasingTitle: "리베이스 중",
ConfirmRebase: "정말로 '{{.checkedOutBranch}}' 을(를) '{{.selectedBranch}}'에 리베이스 하시겠습니까?",
ConfirmMerge: "정말로 '{{.selectedBranch}}' 을(를) '{{.checkedOutBranch}}'에 병합하시겠습니까?",
FwdNoUpstream: "Cannot fast-forward a branch with no upstream",
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",
StagingTitle: "Poczekalnia",
ReturnToFilesPanel: "wróć do panelu plików",
RebasingTitle: "Zmiana bazy",
MergingTitle: "Scalanie",
ConfirmRebase: "Czy napewno chcesz zmienić bazę '{{.checkedOutBranch}}' na '{{.selectedBranch}}'?",
ConfirmMerge: "Czy na pewno chcesz scalić '{{.selectedBranch}}' do '{{.checkedOutBranch}}'?",
FwdNoUpstream: "Nie można przewinąć gałęzi bez gałęzi nadrzędnej",
FwdCommitsToPush: "Nie można przewinąć gałęzi z commitami do wysłania",