diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 803980c50..34da4c8af 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -666,7 +666,7 @@ func (gui *Gui) resetState(startArgs appTypes.StartArgs) types.Context { gui.applySidePanelConfig() - return initialContext(contextTree, startArgs) + return initialContext(contextTree, startArgs, gui.git.Bisect.GetInfo().Started()) } func (gui *Gui) loadCachedPullRequests() []*models.GithubPullRequest { @@ -754,7 +754,7 @@ func parseScreenModeArg(screenModeArg string) types.ScreenMode { } } -func initialContext(contextTree *context.ContextTree, startArgs appTypes.StartArgs) types.IListContext { +func initialContext(contextTree *context.ContextTree, startArgs appTypes.StartArgs, bisectStarted bool) types.IListContext { var initialContext types.IListContext = contextTree.Files if startArgs.FilterPath != "" { @@ -772,6 +772,10 @@ func initialContext(contextTree *context.ContextTree, startArgs appTypes.StartAr default: panic("unhandled git arg") } + } else if bisectStarted { + // The commits panel shows how far the bisect has got, and the user + // marks the commits to test there + initialContext = contextTree.LocalCommits } return initialContext diff --git a/pkg/integration/tests/bisect/start_in_commits_panel.go b/pkg/integration/tests/bisect/start_in_commits_panel.go new file mode 100644 index 000000000..62825e753 --- /dev/null +++ b/pkg/integration/tests/bisect/start_in_commits_panel.go @@ -0,0 +1,32 @@ +package bisect + +import ( + "github.com/jesseduffield/lazygit/pkg/config" + . "github.com/jesseduffield/lazygit/pkg/integration/components" +) + +var StartInCommitsPanel = NewIntegrationTest(NewIntegrationTestArgs{ + Description: "Focus the commits panel at startup when a bisect is in progress", + ExtraCmdArgs: []string{}, + Skip: false, + SetupRepo: func(shell *Shell) { + shell. + CreateNCommits(3). + // The bisect is in progress, although git knows only a bad commit + // so far + RunCommand([]string{"git", "bisect", "start"}). + RunCommand([]string{"git", "bisect", "bad"}) + }, + SetupConfig: func(cfg *config.AppConfig) { + cfg.GetUserConfig().Git.Log.ShowGraph = "never" + }, + Run: func(t *TestDriver, keys config.KeybindingConfig) { + t.Views().Commits(). + IsFocused(). + Lines( + Contains("CI commit-03").Contains("<-- bad").IsSelected(), + Contains("CI commit-02"), + Contains("CI commit-01"), + ) + }, +}) diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go index 04a481279..987713b3c 100644 --- a/pkg/integration/tests/test_list.go +++ b/pkg/integration/tests/test_list.go @@ -45,6 +45,7 @@ var tests = []*components.IntegrationTest{ bisect.StartFromBranches, bisect.StartFromSubCommitsAndReflog, bisect.StartFromTagsAndRemoteBranches, + bisect.StartInCommitsPanel, branch.CheckoutAutostash, branch.CheckoutByName, branch.CheckoutPreviousBranch,