Files
lazygit/pkg/integration/tests/bisect/select_current_commit.go
Stefan HallerandClaude Opus 5.5 208bbce33f Select the current bisect commit whenever it changes
If lazygit starts while a bisect is in progress, the commits view
selects the top commit, and the user has to look for the commit that
git wants them to test. The same happens when a git bisect command run
outside of lazygit moves the bisect on.

The bisect menu selected the new current commit after a good, bad or
skip, but only if the selected commit was the current one. It also
needed extra logic to wait for the refresh in case the log was going to
start from a different ref.

Remove that, and let the commits refresh select the current commit
whenever it differs from the one at the previous refresh, like it does
for a newly conflicted commit. A refresh that doesn't change it leaves
the selection alone. This way a background fetch doesn't move the
selection back to the current commit after the user navigated away from
it.

Marking the current commit as good or bad while a different commit is
selected now selects the new current commit too.

Skipping the selected commit when it isn't the current one is an
exception. Git often picks a different commit to test after that, but
we keep the skipped commit selected, so that the user can go on
skipping commits near it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-31 11:27:58 +01:00

36 lines
1.0 KiB
Go

package bisect
import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
)
var SelectCurrentCommit = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Select the current bisect commit whenever it changes, but not on every refresh",
ExtraCmdArgs: []string{},
Skip: false,
SetupRepo: func(shell *Shell) {
shell.
CreateNCommits(10).
StartBisect("HEAD", "HEAD~9")
},
SetupConfig: func(cfg *config.AppConfig) {
cfg.GetUserConfig().Git.Log.ShowGraph = "never"
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Commits().
Focus().
SelectedLine(Contains("CI commit-05").Contains("<-- current")).
NavigateToLine(Contains("CI commit-08")).
Tap(func() {
t.RefreshInBackground()
}).
SelectedLine(Contains("CI commit-08")).
Tap(func() {
t.Shell().RunCommand([]string{"git", "bisect", "good"})
t.RefreshInBackground()
}).
SelectedLine(Contains("CI commit-07").Contains("<-- current"))
},
})