1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-19 21:28:28 +02:00

Merge pull request #2694 from stefanhaller/conflict-handling-menu

Show menu instead of prompt when there are conflicts in a rebase or merge
This commit is contained in:
Stefan Haller 2023-06-01 10:52:11 +02:00 committed by GitHub
commit 33e5f8f776
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 131 additions and 21 deletions

View File

@ -138,15 +138,26 @@ func (self *MergeAndRebaseHelper) CheckMergeOrRebase(result error) error {
// assume in this case that we're already done // assume in this case that we're already done
return nil return nil
} else if isMergeConflictErr(result.Error()) { } else if isMergeConflictErr(result.Error()) {
return self.c.Confirm(types.ConfirmOpts{ mode := self.workingTreeStateNoun()
Title: self.c.Tr.FoundConflictsTitle, return self.c.Menu(types.CreateMenuOptions{
Prompt: self.c.Tr.FoundConflicts, Title: self.c.Tr.FoundConflictsTitle,
HandleConfirm: func() error { Items: []*types.MenuItem{
return self.c.PushContext(self.c.Contexts().Files) {
}, Label: self.c.Tr.ViewConflictsMenuItem,
HandleClose: func() error { OnPress: func() error {
return self.genericMergeCommand(REBASE_OPTION_ABORT) 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 { } else {
return self.c.ErrorMsg(result.Error()) return self.c.ErrorMsg(result.Error())

View File

@ -175,7 +175,6 @@ func chineseTranslationSet() TranslationSet {
ReturnToFilesPanel: `返回文件面板`, ReturnToFilesPanel: `返回文件面板`,
FastForward: `从上游快进此分支`, FastForward: `从上游快进此分支`,
Fetching: "抓取并快进 {{.from}} -> {{.to}} ...", Fetching: "抓取并快进 {{.from}} -> {{.to}} ...",
FoundConflicts: "冲突!需要中止操作请按‘esc’, 否则按‘enter’",
FoundConflictsTitle: "自动合并失败", FoundConflictsTitle: "自动合并失败",
ViewMergeRebaseOptions: "查看 合并/变基 选项", ViewMergeRebaseOptions: "查看 合并/变基 选项",
NotMergingOrRebasing: "您目前既不进行变基也不进行合并", NotMergingOrRebasing: "您目前既不进行变基也不进行合并",

View File

@ -140,8 +140,7 @@ func dutchTranslationSet() TranslationSet {
ReturnToFilesPanel: `Ga terug naar het bestanden paneel`, ReturnToFilesPanel: `Ga terug naar het bestanden paneel`,
FastForward: `Fast-forward deze branch vanaf zijn upstream`, FastForward: `Fast-forward deze branch vanaf zijn upstream`,
Fetching: "Fetching en fast-forwarding {{.from}} -> {{.to}} ...", Fetching: "Fetching en fast-forwarding {{.from}} -> {{.to}} ...",
FoundConflicts: "Conflicten!, Om af te breken druk 'esc', anders druk op 'enter'", FoundConflictsTitle: "Conflicten!",
FoundConflictsTitle: "Auto-merge mislukt",
ViewMergeRebaseOptions: "Bekijk merge/rebase opties", ViewMergeRebaseOptions: "Bekijk merge/rebase opties",
NotMergingOrRebasing: "Je bent momenteel niet aan het rebasen of mergen", NotMergingOrRebasing: "Je bent momenteel niet aan het rebasen of mergen",
RecentRepos: "Recente repositories", RecentRepos: "Recente repositories",

View File

@ -181,8 +181,9 @@ type TranslationSet struct {
ReturnToFilesPanel string ReturnToFilesPanel string
FastForward string FastForward string
Fetching string Fetching string
FoundConflicts string
FoundConflictsTitle string FoundConflictsTitle string
ViewConflictsMenuItem string
AbortMenuItem string
PickHunk string PickHunk string
PickAllHunks string PickAllHunks string
ViewMergeRebaseOptions string ViewMergeRebaseOptions string
@ -867,8 +868,9 @@ func EnglishTranslationSet() TranslationSet {
ReturnToFilesPanel: `Return to files panel`, ReturnToFilesPanel: `Return to files panel`,
FastForward: `Fast-forward this branch from its upstream`, FastForward: `Fast-forward this branch from its upstream`,
Fetching: "Fetching and fast-forwarding {{.from}} -> {{.to}} ...", Fetching: "Fetching and fast-forwarding {{.from}} -> {{.to}} ...",
FoundConflicts: "Conflicts! To abort press 'esc', otherwise press 'enter'", FoundConflictsTitle: "Conflicts!",
FoundConflictsTitle: "Auto-merge failed", ViewConflictsMenuItem: "View conflicts",
AbortMenuItem: "Abort the %s",
ViewMergeRebaseOptions: "View merge/rebase options", ViewMergeRebaseOptions: "View merge/rebase options",
NotMergingOrRebasing: "You are currently neither rebasing nor merging", NotMergingOrRebasing: "You are currently neither rebasing nor merging",
AlreadyRebasing: "Can't perform this action during a rebase", AlreadyRebasing: "Can't perform this action during a rebase",

View File

@ -176,7 +176,6 @@ func koreanTranslationSet() TranslationSet {
ReturnToFilesPanel: `파일 목록으로 돌아가기`, ReturnToFilesPanel: `파일 목록으로 돌아가기`,
FastForward: `Fast-forward this branch from its upstream`, FastForward: `Fast-forward this branch from its upstream`,
Fetching: "Fetching and fast-forwarding {{.from}} -> {{.to}} ...", Fetching: "Fetching and fast-forwarding {{.from}} -> {{.to}} ...",
FoundConflicts: "Conflicts! To abort press 'esc', otherwise press 'enter'",
FoundConflictsTitle: "Auto-merge failed", FoundConflictsTitle: "Auto-merge failed",
ViewMergeRebaseOptions: "View merge/rebase options", ViewMergeRebaseOptions: "View merge/rebase options",
NotMergingOrRebasing: "You are currently neither rebasing nor merging", NotMergingOrRebasing: "You are currently neither rebasing nor merging",

View File

@ -125,8 +125,7 @@ func polishTranslationSet() TranslationSet {
MoveUpCommit: "Przenieś commit 1 w górę", MoveUpCommit: "Przenieś commit 1 w górę",
EditCommit: "Edytuj commit", EditCommit: "Edytuj commit",
AmendToCommit: "Popraw commit zmianami z poczekalni", AmendToCommit: "Popraw commit zmianami z poczekalni",
FoundConflicts: "Konflikty! Wciśnij 'esc' żeby przerwać, w przeciwnym razie wciśnij 'enter'", FoundConflictsTitle: "Konflikty!",
FoundConflictsTitle: "Automatyczne scalenie nie powiodło się",
ViewMergeRebaseOptions: "Widok scalenia/opcje zmiany bazy", ViewMergeRebaseOptions: "Widok scalenia/opcje zmiany bazy",
NotMergingOrRebasing: "W tej chwili nie scalasz ani nie zmieniasz bazy", NotMergingOrRebasing: "W tej chwili nie scalasz ani nie zmieniasz bazy",
RecentRepos: "Ostatnie repozytoria", RecentRepos: "Ostatnie repozytoria",

View File

@ -240,7 +240,6 @@ func traditionalChineseTranslationSet() TranslationSet {
ReturnToFilesPanel: `返回檔案面板`, ReturnToFilesPanel: `返回檔案面板`,
FastForward: `從上游快進此分支`, FastForward: `從上游快進此分支`,
Fetching: "{{.from}} -> {{.to}} 的擷取和快進中...", Fetching: "{{.from}} -> {{.to}} 的擷取和快進中...",
FoundConflicts: "衝突!按 'esc' 退出,否則按 'enter'",
FoundConflictsTitle: "自動合併失敗", FoundConflictsTitle: "自動合併失敗",
ViewMergeRebaseOptions: "查看合併/變基選項", ViewMergeRebaseOptions: "查看合併/變基選項",
NotMergingOrRebasing: "你當前既不在變基也不在合併中", NotMergingOrRebasing: "你當前既不在變基也不在合併中",

View File

@ -19,9 +19,9 @@ func (self *Common) ContinueRebase() {
} }
func (self *Common) AcknowledgeConflicts() { func (self *Common) AcknowledgeConflicts() {
self.t.ExpectPopup().Confirmation(). self.t.ExpectPopup().Menu().
Title(Equals("Auto-merge failed")). Title(Equals("Conflicts!")).
Content(Contains("Conflicts!")). Select(Contains("View conflicts")).
Confirm() Confirm()
} }

View 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()
},
})

View 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"),
)
},
})

View File

@ -36,7 +36,9 @@ var tests = []*components.IntegrationTest{
branch.DetachedHead, branch.DetachedHead,
branch.OpenWithCliArg, branch.OpenWithCliArg,
branch.Rebase, branch.Rebase,
branch.RebaseAbortOnConflict,
branch.RebaseAndDrop, branch.RebaseAndDrop,
branch.RebaseCancelOnConflict,
branch.RebaseDoesNotAutosquash, branch.RebaseDoesNotAutosquash,
branch.Reset, branch.Reset,
branch.ResetUpstream, branch.ResetUpstream,