Skip to content

Commit 90b5aef

Browse files
committed
fix
1 parent 7706924 commit 90b5aef

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

templates/repo/commits.tmpl

+14-12
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,19 @@
55
{{template "repo/sub_menu" .}}
66
<div class="repo-button-row">
77
<div class="repo-button-row-left">
8-
9-
{{$branchDropdownCurrentRefType := "branch"}}
10-
{{$branchDropdownCurrentRefShortName := .RefName}}
11-
{{if .IsViewTag}}
12-
{{$branchDropdownCurrentRefType = "tag"}}
13-
{{$branchDropdownCurrentRefShortName = .TagName}}
14-
{{else if not .IsViewBranch}}
15-
{{$branchDropdownCurrentRefShortName = ShortSha .RefName}}
16-
{{end}}
17-
{{template "repo/branch_dropdown" dict
8+
{{- /* for /owner/repo/commits/branch/the-name */ -}}
9+
{{- $branchDropdownCurrentRefType := "branch" -}}
10+
{{- $branchDropdownCurrentRefShortName := .BranchName -}}
11+
{{- if .IsViewTag -}}
12+
{{- /* for /owner/repo/commits/tag/the-name */ -}}
13+
{{- $branchDropdownCurrentRefType = "tag" -}}
14+
{{- $branchDropdownCurrentRefShortName = .TagName -}}
15+
{{- else if .IsViewCommit -}}
16+
{{- /* for /owner/repo/commits/commit/000000 */ -}}
17+
{{- $branchDropdownCurrentRefType = "commit" -}}
18+
{{- $branchDropdownCurrentRefShortName = ShortSha .CommitID -}}
19+
{{- end -}}
20+
{{- template "repo/branch_dropdown" dict
1821
"Repository" .Repository
1922
"ShowTabBranches" true
2023
"ShowTabTags" true
@@ -23,8 +26,7 @@
2326
"CurrentTreePath" .TreePath
2427
"RefLinkTemplate" "{RepoLink}/commits/{RefType}/{RefShortName}/{TreePath}"
2528
"AllowCreateNewRef" .CanCreateBranch
26-
}}
27-
29+
-}}
2830
<a href="{{.RepoLink}}/graph" class="ui basic small compact button">
2931
{{svg "octicon-git-branch"}}
3032
{{ctx.Locale.Tr "repo.commit_graph"}}

templates/repo/home.tmpl

+14-10
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@
2424
{{template "repo/sub_menu" .}}
2525
<div class="repo-button-row">
2626
<div class="repo-button-row-left">
27-
{{$branchDropdownCurrentRefType := "branch"}}
28-
{{$branchDropdownCurrentRefShortName := .RefName}}
29-
{{if .IsViewTag}}
30-
{{$branchDropdownCurrentRefType = "tag"}}
31-
{{$branchDropdownCurrentRefShortName = .TagName}}
32-
{{else if not .IsViewBranch}}
33-
{{$branchDropdownCurrentRefShortName = ShortSha .RefName}}
34-
{{end}}
35-
{{template "repo/branch_dropdown" dict
27+
{{- /* for repo home (default branch) and /owner/repo/src/branch/the-name */ -}}
28+
{{- $branchDropdownCurrentRefType := "branch" -}}
29+
{{- $branchDropdownCurrentRefShortName := .BranchName -}}
30+
{{- if .IsViewTag -}}
31+
{{- /* for /owner/repo/src/tag/the-name */ -}}
32+
{{- $branchDropdownCurrentRefType = "tag" -}}
33+
{{- $branchDropdownCurrentRefShortName = .TagName -}}
34+
{{- else if .IsViewCommit -}}
35+
{{- /* for /owner/repo/src/commit/000000 */ -}}
36+
{{- $branchDropdownCurrentRefType = "commit" -}}
37+
{{- $branchDropdownCurrentRefShortName = ShortSha .CommitID -}}
38+
{{- end -}}
39+
{{- template "repo/branch_dropdown" dict
3640
"Repository" .Repository
3741
"ShowTabBranches" true
3842
"ShowTabTags" true
@@ -42,7 +46,7 @@
4246
"RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}"
4347
"AllowCreateNewRef" .CanCreateBranch
4448
"ShowViewAllRefsEntry" true
45-
}}
49+
-}}
4650
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
4751
{{$cmpBranch := ""}}
4852
{{if ne .Repository.ID .BaseRepo.ID}}

0 commit comments

Comments
 (0)