Skip to content

Commit 35f0b5a

Browse files
ajmeese7wxiaoguang
andauthored
Adds tooltip on branch commit counts (#34869)
Adds a tooltip to the commit counts when comparing branches, making it easier for novice users to understand what the numbers mean. Fixes #34867. --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parent 90f96c3 commit 35f0b5a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,6 +2769,8 @@ branch.new_branch_from = Create new branch from "%s"
27692769
branch.renamed = Branch %s was renamed to %s.
27702770
branch.rename_default_or_protected_branch_error = Only admins can rename default or protected branches.
27712771
branch.rename_protected_branch_failed = This branch is protected by glob-based protection rules.
2772+
branch.commits_divergence_from = Commits divergence: %[1]d behind and %[2]d ahead of %[3]s
2773+
branch.commits_no_divergence = The same as branch %[1]s
27722774
27732775
tag.create_tag = Create tag %s
27742776
tag.create_tag_operation = Create tag

templates/repo/branch/list.tmpl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,14 @@
107107
{{end}}
108108
</td>
109109
<td class="two wide ui">
110-
{{if and (not .DBBranch.IsDeleted) $.DefaultBranchBranch}}
111-
<div class="commit-divergence">
110+
{{if and (not .DBBranch.IsDeleted) $.DefaultBranchBranch}}
111+
{{$tooltipDivergence := ""}}
112+
{{if or .CommitsBehind .CommitsAhead}}
113+
{{$tooltipDivergence = ctx.Locale.Tr "repo.branch.commits_divergence_from" .CommitsBehind .CommitsAhead $.DefaultBranchBranch.DBBranch.Name}}
114+
{{else}}
115+
{{$tooltipDivergence = ctx.Locale.Tr "repo.branch.commits_no_divergence" $.DefaultBranchBranch.DBBranch.Name}}
116+
{{end}}
117+
<div class="commit-divergence" data-tooltip-content="{{$tooltipDivergence}}">
112118
<div class="bar-group">
113119
<div class="count count-behind">{{.CommitsBehind}}</div>
114120
{{/* old code bears 0/0.0 = NaN output, so it might output invalid "width: NaNpx", it just works and doesn't caues any problem. */}}
@@ -119,7 +125,7 @@
119125
<div class="bar bar-ahead" style="width: {{Eval 100 "*" .CommitsAhead "/" "(" .CommitsBehind "+" .CommitsAhead "+" 0.0 ")"}}%"></div>
120126
</div>
121127
</div>
122-
{{end}}
128+
{{end}}
123129
</td>
124130
<td class="two wide tw-text-right">
125131
{{if not .LatestPullRequest}}

0 commit comments

Comments
 (0)