mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-03-03 15:02:52 +02:00
Show menu instead of prompt when there are conflicts in a rebase or merge
This solves the issue that previously you could too easily abort a rebase accidentally by hitting escape.
This commit is contained in:
parent
c70c8e84f8
commit
16dceb813b
@ -138,15 +138,26 @@ func (self *MergeAndRebaseHelper) CheckMergeOrRebase(result error) error {
|
||||
// assume in this case that we're already done
|
||||
return nil
|
||||
} else if isMergeConflictErr(result.Error()) {
|
||||
return self.c.Confirm(types.ConfirmOpts{
|
||||
Title: self.c.Tr.FoundConflictsTitle,
|
||||
Prompt: self.c.Tr.FoundConflicts,
|
||||
HandleConfirm: func() error {
|
||||
return self.c.PushContext(self.c.Contexts().Files)
|
||||
},
|
||||
HandleClose: func() error {
|
||||
return self.genericMergeCommand(REBASE_OPTION_ABORT)
|
||||
mode := self.workingTreeStateNoun()
|
||||
return self.c.Menu(types.CreateMenuOptions{
|
||||
Title: self.c.Tr.FoundConflictsTitle,
|
||||
Items: []*types.MenuItem{
|
||||
{
|
||||
Label: self.c.Tr.ViewConflictsMenuItem,
|
||||
OnPress: func() error {
|
||||
return self.c.PushContext(self.c.Contexts().Files)
|
||||
},
|
||||
Key: 'v',
|
||||
},
|
||||
{
|
||||
Label: fmt.Sprintf(self.c.Tr.AbortMenuItem, mode),
|
||||
OnPress: func() error {
|
||||
return self.genericMergeCommand(REBASE_OPTION_ABORT)
|
||||
},
|
||||
Key: 'a',
|
||||
},
|
||||
},
|
||||
HideCancel: true,
|
||||
})
|
||||
} else {
|
||||
return self.c.ErrorMsg(result.Error())
|
||||
|
@ -175,7 +175,6 @@ func chineseTranslationSet() TranslationSet {
|
||||
ReturnToFilesPanel: `返回文件面板`,
|
||||
FastForward: `从上游快进此分支`,
|
||||
Fetching: "抓取并快进 {{.from}} -> {{.to}} ...",
|
||||
FoundConflicts: "冲突!需要中止操作请按‘esc’, 否则按‘enter’",
|
||||
FoundConflictsTitle: "自动合并失败",
|
||||
ViewMergeRebaseOptions: "查看 合并/变基 选项",
|
||||
NotMergingOrRebasing: "您目前既不进行变基也不进行合并",
|
||||
|
@ -140,8 +140,7 @@ func dutchTranslationSet() TranslationSet {
|
||||
ReturnToFilesPanel: `Ga terug naar het bestanden paneel`,
|
||||
FastForward: `Fast-forward deze branch vanaf zijn upstream`,
|
||||
Fetching: "Fetching en fast-forwarding {{.from}} -> {{.to}} ...",
|
||||
FoundConflicts: "Conflicten!, Om af te breken druk 'esc', anders druk op 'enter'",
|
||||
FoundConflictsTitle: "Auto-merge mislukt",
|
||||
FoundConflictsTitle: "Conflicten!",
|
||||
ViewMergeRebaseOptions: "Bekijk merge/rebase opties",
|
||||
NotMergingOrRebasing: "Je bent momenteel niet aan het rebasen of mergen",
|
||||
RecentRepos: "Recente repositories",
|
||||
|
@ -181,8 +181,9 @@ type TranslationSet struct {
|
||||
ReturnToFilesPanel string
|
||||
FastForward string
|
||||
Fetching string
|
||||
FoundConflicts string
|
||||
FoundConflictsTitle string
|
||||
ViewConflictsMenuItem string
|
||||
AbortMenuItem string
|
||||
PickHunk string
|
||||
PickAllHunks string
|
||||
ViewMergeRebaseOptions string
|
||||
@ -867,8 +868,9 @@ func EnglishTranslationSet() TranslationSet {
|
||||
ReturnToFilesPanel: `Return to files panel`,
|
||||
FastForward: `Fast-forward this branch from its upstream`,
|
||||
Fetching: "Fetching and fast-forwarding {{.from}} -> {{.to}} ...",
|
||||
FoundConflicts: "Conflicts! To abort press 'esc', otherwise press 'enter'",
|
||||
FoundConflictsTitle: "Auto-merge failed",
|
||||
FoundConflictsTitle: "Conflicts!",
|
||||
ViewConflictsMenuItem: "View conflicts",
|
||||
AbortMenuItem: "Abort the %s",
|
||||
ViewMergeRebaseOptions: "View merge/rebase options",
|
||||
NotMergingOrRebasing: "You are currently neither rebasing nor merging",
|
||||
AlreadyRebasing: "Can't perform this action during a rebase",
|
||||
|
@ -176,7 +176,6 @@ func koreanTranslationSet() TranslationSet {
|
||||
ReturnToFilesPanel: `파일 목록으로 돌아가기`,
|
||||
FastForward: `Fast-forward this branch from its upstream`,
|
||||
Fetching: "Fetching and fast-forwarding {{.from}} -> {{.to}} ...",
|
||||
FoundConflicts: "Conflicts! To abort press 'esc', otherwise press 'enter'",
|
||||
FoundConflictsTitle: "Auto-merge failed",
|
||||
ViewMergeRebaseOptions: "View merge/rebase options",
|
||||
NotMergingOrRebasing: "You are currently neither rebasing nor merging",
|
||||
|
@ -125,8 +125,7 @@ func polishTranslationSet() TranslationSet {
|
||||
MoveUpCommit: "Przenieś commit 1 w górę",
|
||||
EditCommit: "Edytuj commit",
|
||||
AmendToCommit: "Popraw commit zmianami z poczekalni",
|
||||
FoundConflicts: "Konflikty! Wciśnij 'esc' żeby przerwać, w przeciwnym razie wciśnij 'enter'",
|
||||
FoundConflictsTitle: "Automatyczne scalenie nie powiodło się",
|
||||
FoundConflictsTitle: "Konflikty!",
|
||||
ViewMergeRebaseOptions: "Widok scalenia/opcje zmiany bazy",
|
||||
NotMergingOrRebasing: "W tej chwili nie scalasz ani nie zmieniasz bazy",
|
||||
RecentRepos: "Ostatnie repozytoria",
|
||||
|
@ -240,7 +240,6 @@ func traditionalChineseTranslationSet() TranslationSet {
|
||||
ReturnToFilesPanel: `返回檔案面板`,
|
||||
FastForward: `從上游快進此分支`,
|
||||
Fetching: "{{.from}} -> {{.to}} 的擷取和快進中...",
|
||||
FoundConflicts: "衝突!按 'esc' 退出,否則按 'enter'",
|
||||
FoundConflictsTitle: "自動合併失敗",
|
||||
ViewMergeRebaseOptions: "查看合併/變基選項",
|
||||
NotMergingOrRebasing: "你當前既不在變基也不在合併中",
|
||||
|
@ -19,9 +19,9 @@ func (self *Common) ContinueRebase() {
|
||||
}
|
||||
|
||||
func (self *Common) AcknowledgeConflicts() {
|
||||
self.t.ExpectPopup().Confirmation().
|
||||
Title(Equals("Auto-merge failed")).
|
||||
Content(Contains("Conflicts!")).
|
||||
self.t.ExpectPopup().Menu().
|
||||
Title(Equals("Conflicts!")).
|
||||
Select(Contains("View conflicts")).
|
||||
Confirm()
|
||||
}
|
||||
|
||||
|
49
pkg/integration/tests/branch/rebase_abort_on_conflict.go
Normal file
49
pkg/integration/tests/branch/rebase_abort_on_conflict.go
Normal file
@ -0,0 +1,49 @@
|
||||
package branch
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
|
||||
)
|
||||
|
||||
var RebaseAbortOnConflict = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Rebase onto another branch, abort when there are conflicts.",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shared.MergeConflictsSetup(shell)
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().TopLines(
|
||||
Contains("first change"),
|
||||
Contains("original"),
|
||||
)
|
||||
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first-change-branch"),
|
||||
Contains("second-change-branch"),
|
||||
Contains("original-branch"),
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Branches.RebaseBranch)
|
||||
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Rebase 'first-change-branch' onto 'second-change-branch'")).
|
||||
Select(Contains("Simple rebase")).
|
||||
Confirm()
|
||||
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Conflicts!")).
|
||||
Select(Contains("Abort the rebase")).
|
||||
Confirm()
|
||||
|
||||
t.Views().Branches().
|
||||
IsFocused()
|
||||
|
||||
t.Views().Files().
|
||||
IsEmpty()
|
||||
},
|
||||
})
|
51
pkg/integration/tests/branch/rebase_cancel_on_conflict.go
Normal file
51
pkg/integration/tests/branch/rebase_cancel_on_conflict.go
Normal file
@ -0,0 +1,51 @@
|
||||
package branch
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
"github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
|
||||
)
|
||||
|
||||
var RebaseCancelOnConflict = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Rebase onto another branch, cancel when there are conflicts.",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shared.MergeConflictsSetup(shell)
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
t.Views().Commits().TopLines(
|
||||
Contains("first change"),
|
||||
Contains("original"),
|
||||
)
|
||||
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
Lines(
|
||||
Contains("first-change-branch"),
|
||||
Contains("second-change-branch"),
|
||||
Contains("original-branch"),
|
||||
).
|
||||
SelectNextItem().
|
||||
Press(keys.Branches.RebaseBranch)
|
||||
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Rebase 'first-change-branch' onto 'second-change-branch'")).
|
||||
Select(Contains("Simple rebase")).
|
||||
Confirm()
|
||||
|
||||
t.ExpectPopup().Menu().
|
||||
Title(Equals("Conflicts!")).
|
||||
Select(Contains("Abort the rebase")).
|
||||
Cancel()
|
||||
|
||||
t.Views().Branches().
|
||||
IsFocused()
|
||||
|
||||
t.Views().Files().
|
||||
Lines(
|
||||
Contains("UU file"),
|
||||
)
|
||||
},
|
||||
})
|
@ -36,7 +36,9 @@ var tests = []*components.IntegrationTest{
|
||||
branch.DetachedHead,
|
||||
branch.OpenWithCliArg,
|
||||
branch.Rebase,
|
||||
branch.RebaseAbortOnConflict,
|
||||
branch.RebaseAndDrop,
|
||||
branch.RebaseCancelOnConflict,
|
||||
branch.RebaseDoesNotAutosquash,
|
||||
branch.Reset,
|
||||
branch.ResetUpstream,
|
||||
|
Loading…
x
Reference in New Issue
Block a user