mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
Don't show branch heads in reflog subcommits
It's tricky to get this right for reflog commits wrt what's the current branch for each one; so just disable it entirely here, it's probably not something anybody needs here.
This commit is contained in:
parent
6dc25d796b
commit
f5c9764dd2
8 changed files with 105 additions and 2 deletions
|
@ -83,3 +83,7 @@ func (self *BranchesContext) GetDiffTerminals() []string {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *BranchesContext) ShowBranchHeadsInSubCommits() bool {
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -86,3 +86,7 @@ func (self *ReflogCommitsContext) GetDiffTerminals() []string {
|
|||
|
||||
return []string{itemId}
|
||||
}
|
||||
|
||||
func (self *ReflogCommitsContext) ShowBranchHeadsInSubCommits() bool {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -72,3 +72,7 @@ func (self *RemoteBranchesContext) GetDiffTerminals() []string {
|
|||
|
||||
return []string{itemId}
|
||||
}
|
||||
|
||||
func (self *RemoteBranchesContext) ShowBranchHeadsInSubCommits() bool {
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -51,10 +51,14 @@ func NewSubCommitsContext(
|
|||
selectedCommitSha = selectedCommit.Sha
|
||||
}
|
||||
}
|
||||
branches := []*models.Branch{}
|
||||
if viewModel.GetShowBranchHeads() {
|
||||
branches = c.Model().Branches
|
||||
}
|
||||
return presentation.GetCommitListDisplayStrings(
|
||||
c.Common,
|
||||
c.Model().SubCommits,
|
||||
c.Model().Branches,
|
||||
branches,
|
||||
viewModel.GetRef().RefName(),
|
||||
c.State().GetRepoState().GetScreenMode() != types.SCREEN_NORMAL,
|
||||
c.Modes().CherryPicking.SelectedShaSet(),
|
||||
|
@ -106,7 +110,8 @@ type SubCommitsViewModel struct {
|
|||
ref types.Ref
|
||||
*ListViewModel[*models.Commit]
|
||||
|
||||
limitCommits bool
|
||||
limitCommits bool
|
||||
showBranchHeads bool
|
||||
}
|
||||
|
||||
func (self *SubCommitsViewModel) SetRef(ref types.Ref) {
|
||||
|
@ -117,6 +122,14 @@ func (self *SubCommitsViewModel) GetRef() types.Ref {
|
|||
return self.ref
|
||||
}
|
||||
|
||||
func (self *SubCommitsViewModel) SetShowBranchHeads(value bool) {
|
||||
self.showBranchHeads = value
|
||||
}
|
||||
|
||||
func (self *SubCommitsViewModel) GetShowBranchHeads() bool {
|
||||
return self.showBranchHeads
|
||||
}
|
||||
|
||||
func (self *SubCommitsContext) GetSelectedItemId() string {
|
||||
item := self.GetSelected()
|
||||
if item == nil {
|
||||
|
|
|
@ -69,3 +69,7 @@ func (self *TagsContext) GetDiffTerminals() []string {
|
|||
|
||||
return []string{itemId}
|
||||
}
|
||||
|
||||
func (self *TagsContext) ShowBranchHeadsInSubCommits() bool {
|
||||
return true
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ var _ types.IController = &SwitchToSubCommitsController{}
|
|||
type CanSwitchToSubCommits interface {
|
||||
types.Context
|
||||
GetSelectedRef() types.Ref
|
||||
ShowBranchHeadsInSubCommits() bool
|
||||
}
|
||||
|
||||
type SwitchToSubCommitsController struct {
|
||||
|
@ -79,6 +80,7 @@ func (self *SwitchToSubCommitsController) viewCommits() error {
|
|||
subCommitsContext.SetTitleRef(ref.Description())
|
||||
subCommitsContext.SetRef(ref)
|
||||
subCommitsContext.SetLimitCommits(true)
|
||||
subCommitsContext.SetShowBranchHeads(self.context.ShowBranchHeadsInSubCommits())
|
||||
subCommitsContext.ClearSearchString()
|
||||
subCommitsContext.GetView().ClearSearch()
|
||||
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package reflog
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/config"
|
||||
. "github.com/jesseduffield/lazygit/pkg/integration/components"
|
||||
)
|
||||
|
||||
var DoNotShowBranchMarkersInReflogSubcommits = NewIntegrationTest(NewIntegrationTestArgs{
|
||||
Description: "Verify that no branch heads are shown in the subcommits view of a reflog entry",
|
||||
ExtraCmdArgs: []string{},
|
||||
Skip: false,
|
||||
SetupConfig: func(config *config.AppConfig) {},
|
||||
SetupRepo: func(shell *Shell) {
|
||||
shell.NewBranch("branch1")
|
||||
shell.EmptyCommit("one")
|
||||
shell.EmptyCommit("two")
|
||||
shell.NewBranch("branch2")
|
||||
shell.EmptyCommit("three")
|
||||
},
|
||||
Run: func(t *TestDriver, keys config.KeybindingConfig) {
|
||||
// Check that the local commits view does show a branch marker for branch1
|
||||
t.Views().Commits().
|
||||
Lines(
|
||||
Contains("CI three"),
|
||||
Contains("CI * two"),
|
||||
Contains("CI one"),
|
||||
)
|
||||
|
||||
t.Views().Branches().
|
||||
Focus().
|
||||
// Check out branch1
|
||||
NavigateToLine(Contains("branch1")).
|
||||
PressPrimaryAction().
|
||||
// Look at the subcommits of branch2
|
||||
NavigateToLine(Contains("branch2")).
|
||||
PressEnter().
|
||||
// Check that we see a marker for branch1 here (but not for
|
||||
// branch2), even though branch1 is checked out
|
||||
Tap(func() {
|
||||
t.Views().SubCommits().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("CI three"),
|
||||
Contains("CI * two"),
|
||||
Contains("CI one"),
|
||||
).
|
||||
PressEscape()
|
||||
}).
|
||||
// Check out branch2 again
|
||||
NavigateToLine(Contains("branch2")).
|
||||
PressPrimaryAction()
|
||||
|
||||
t.Views().ReflogCommits().
|
||||
Focus().
|
||||
TopLines(
|
||||
Contains("checkout: moving from branch1 to branch2").IsSelected(),
|
||||
).
|
||||
PressEnter().
|
||||
// Check that the subcommits view for a reflog entry doesn't show
|
||||
// any branch markers
|
||||
Tap(func() {
|
||||
t.Views().SubCommits().
|
||||
IsFocused().
|
||||
Lines(
|
||||
Contains("CI three"),
|
||||
Contains("CI two"),
|
||||
Contains("CI one"),
|
||||
)
|
||||
})
|
||||
},
|
||||
})
|
|
@ -163,6 +163,7 @@ var tests = []*components.IntegrationTest{
|
|||
patch_building.StartNewPatch,
|
||||
reflog.Checkout,
|
||||
reflog.CherryPick,
|
||||
reflog.DoNotShowBranchMarkersInReflogSubcommits,
|
||||
reflog.Patch,
|
||||
reflog.Reset,
|
||||
staging.DiffContextChange,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue