mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-08-28 02:24:49 -05:00
When conflicts of an in-progress rebase/merge/cherry-pick/revert are resolved, lazygit pops up a prompt offering to continue it. This is helpful when you started the operation in lazygit and resolved the conflicts in your editor. But it's confusing when the operation was started outside lazygit — e.g. by a coding agent in another terminal that resolves the conflicts but hasn't continued yet because it's still running tests or fixing the build. lazygit would then prompt unbidden. Track whether the in-progress operation was started from within lazygit, and only show the prompt in that case. We record this right after running a merge/rebase step (in CheckMergeOrRebaseWithRefreshOptions, the subprocess branch of genericMergeCommand, and the custom-command conflict path), and clear it whenever a refresh observes that no operation is in progress — which also handles an operation that was finished or aborted externally. The conflict-resolution tests start their operation by running git directly (not through lazygit's UI), so they call the new test helper Common.PretendMergeOrRebaseStartedInLazygit to have lazygit treat the operation as its own and still get the prompt. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
101 lines
2.6 KiB
Go
101 lines
2.6 KiB
Go
package components
|
|
|
|
import "fmt"
|
|
|
|
// for running common actions
|
|
type Common struct {
|
|
t *TestDriver
|
|
}
|
|
|
|
func (self *Common) ContinueMerge() {
|
|
self.t.GlobalPress(self.t.keys.Universal.CreateRebaseOptionsMenu)
|
|
|
|
self.t.ExpectPopup().Menu().
|
|
Title(Equals("Rebase options")).
|
|
Select(Contains("continue")).
|
|
Confirm()
|
|
}
|
|
|
|
func (self *Common) ContinueRebase() {
|
|
self.ContinueMerge()
|
|
}
|
|
|
|
func (self *Common) AbortRebase() {
|
|
self.t.GlobalPress(self.t.keys.Universal.CreateRebaseOptionsMenu)
|
|
|
|
self.t.ExpectPopup().Menu().
|
|
Title(Equals("Rebase options")).
|
|
Select(Contains("abort")).
|
|
Confirm()
|
|
}
|
|
|
|
func (self *Common) AbortMerge() {
|
|
self.t.GlobalPress(self.t.keys.Universal.CreateRebaseOptionsMenu)
|
|
|
|
self.t.ExpectPopup().Menu().
|
|
Title(Equals("Merge options")).
|
|
Select(Contains("abort")).
|
|
Confirm()
|
|
}
|
|
|
|
// PretendMergeOrRebaseStartedInLazygit tells lazygit to treat the in-progress
|
|
// rebase/merge/etc. as one that it started, so that it will prompt to continue
|
|
// once the conflicts are resolved. Use it when a test sets up an operation by
|
|
// running git directly rather than through lazygit's UI.
|
|
func (self *Common) PretendMergeOrRebaseStartedInLazygit() {
|
|
self.t.gui.PretendMergeOrRebaseStartedInLazygit()
|
|
}
|
|
|
|
func (self *Common) AcknowledgeConflicts() {
|
|
self.t.ExpectPopup().Menu().
|
|
Title(Equals("Conflicts!")).
|
|
Select(Contains("View conflicts")).
|
|
Confirm()
|
|
}
|
|
|
|
func (self *Common) ContinueOnConflictsResolved(command string) {
|
|
self.t.ExpectPopup().Confirmation().
|
|
Title(Equals("Continue")).
|
|
Content(Contains(fmt.Sprintf("All merge conflicts resolved. Continue the %s?", command))).
|
|
Confirm()
|
|
}
|
|
|
|
func (self *Common) ConfirmDiscardLines() {
|
|
self.t.ExpectPopup().Confirmation().
|
|
Title(Equals("Discard change")).
|
|
Content(Contains("Are you sure you want to discard this change")).
|
|
Confirm()
|
|
}
|
|
|
|
func (self *Common) SelectPatchOption(matcher *TextMatcher) {
|
|
self.t.GlobalPress(self.t.keys.Universal.CreatePatchOptionsMenu)
|
|
|
|
self.t.ExpectPopup().Menu().Title(Equals("Patch options")).Select(matcher).Confirm()
|
|
}
|
|
|
|
func (self *Common) ResetBisect() {
|
|
self.t.Views().Commits().
|
|
Focus().
|
|
Press(self.t.keys.Commits.ViewBisectOptions).
|
|
Tap(func() {
|
|
self.t.ExpectPopup().Menu().
|
|
Title(Equals("Bisect")).
|
|
Select(Contains("Reset bisect")).
|
|
Confirm()
|
|
|
|
self.t.ExpectPopup().Confirmation().
|
|
Title(Equals("Reset 'git bisect'")).
|
|
Content(Contains("Are you sure you want to reset 'git bisect'?")).
|
|
Confirm()
|
|
})
|
|
}
|
|
|
|
func (self *Common) ResetCustomPatch() {
|
|
self.t.GlobalPress(self.t.keys.Universal.CreatePatchOptionsMenu)
|
|
|
|
self.t.ExpectPopup().Menu().
|
|
Title(Equals("Patch options")).
|
|
Select(Contains("Reset patch")).
|
|
Confirm()
|
|
}
|