diff options
Diffstat (limited to 'pkg/gui/presentation/commits.go')
-rw-r--r-- | pkg/gui/presentation/commits.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/pkg/gui/presentation/commits.go b/pkg/gui/presentation/commits.go index 53d3aaf0d..4affe6a57 100644 --- a/pkg/gui/presentation/commits.go +++ b/pkg/gui/presentation/commits.go @@ -39,6 +39,8 @@ type bisectBounds struct { func GetCommitListDisplayStrings( common *common.Common, commits []*models.Commit, + branches []*models.Branch, + currentBranchName string, fullDescription bool, cherryPickedCommitShaSet *set.Set[string], diffName string, @@ -99,6 +101,24 @@ func GetCommitListDisplayStrings( getGraphLine = func(idx int) string { return "" } } + // Determine the hashes of the local branches for which we want to show a + // branch marker in the commits list. We only want to do this for branches + // that are not the current branch, and not any of the main branches. The + // goal is to visualize stacks of local branches, so anything that doesn't + // contribute to a branch stack shouldn't show a marker. + branchHeadsToVisualize := set.NewFromSlice(lo.FilterMap(branches, + func(b *models.Branch, index int) (string, bool) { + return b.CommitHash, + // Don't consider branches that don't have a commit hash. As far + // as I can see, this happens for a detached head, so filter + // these out + b.CommitHash != "" && + // Don't show a marker for the current branch + b.Name != currentBranchName && + // Don't show a marker for main branches + !lo.Contains(common.UserConfig.Git.MainBranches, b.Name) + })) + lines := make([][]string, 0, len(filteredCommits)) var bisectStatus BisectStatus for i, commit := range filteredCommits { @@ -112,6 +132,7 @@ func GetCommitListDisplayStrings( lines = append(lines, displayCommit( common, commit, + branchHeadsToVisualize, cherryPickedCommitShaSet, diffName, timeFormat, @@ -260,6 +281,7 @@ func getBisectStatusText(bisectStatus BisectStatus, bisectInfo *git_commands.Bis func displayCommit( common *common.Common, commit *models.Commit, + branchHeadsToVisualize *set.Set[string], cherryPickedCommitShaSet *set.Set[string], diffName string, timeFormat string, @@ -290,6 +312,11 @@ func displayCommit( if len(commit.Tags) > 0 { tagString = theme.DiffTerminalColor.SetBold().Sprint(strings.Join(commit.Tags, " ")) + " " } + + if branchHeadsToVisualize.Includes(commit.Sha) && commit.Status != models.StatusMerged { + tagString = style.FgCyan.SetBold().Sprint( + lo.Ternary(icons.IsIconEnabled(), icons.BRANCH_ICON, "*") + " " + tagString) + } } name := commit.Name |