Files
Stefan HallerandClaude Opus 4.8 ad507d67f4 Only prompt to continue a rebase/merge if we started it
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>
2026-07-03 18:28:07 +02:00

36 lines
972 B
Go

package conflicts
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
"github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
)
var ResolveExternally = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Ensures that when merge conflicts are resolved outside of lazygit, lazygit prompts you to continue",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shared.CreateMergeConflictFile(shell)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Common().PretendMergeOrRebaseStartedInLazygit()
t.Views().Files().
IsFocused().
Lines(
Contains("UU file").IsSelected(),
).
Tap(func() {
t.Shell().UpdateFile("file", "resolved content")
}).
Press(keys.Universal.Refresh)
t.Common().ContinueOnConflictsResolved("merge")
t.Views().Files().
IsEmpty()
},
})