diff --git a/templates/repo/home_branch_dropdown.tmpl b/templates/repo/home_branch_dropdown.tmpl index eea8abbbf4..08255f482b 100644 --- a/templates/repo/home_branch_dropdown.tmpl +++ b/templates/repo/home_branch_dropdown.tmpl @@ -1,9 +1,15 @@ -{{$branchDropdownCurrentRefType := "branch"}} -{{$branchDropdownCurrentRefShortName := .ctxData.BranchName}} -{{if .ctxData.IsViewTag}} - {{$branchDropdownCurrentRefType = "tag"}} - {{$branchDropdownCurrentRefShortName = .ctxData.TagName}} -{{end}} +{{- /* for repo home (default branch) and /owner/repo/src/branch/the-name */ -}} +{{- $branchDropdownCurrentRefType := "branch" -}} +{{- $branchDropdownCurrentRefShortName := .ctxData.BranchName -}} +{{- if .IsViewTag -}} + {{- /* for /owner/repo/src/tag/the-name */ -}} + {{- $branchDropdownCurrentRefType = "tag" -}} + {{- $branchDropdownCurrentRefShortName = .ctxData.TagName -}} +{{- else if .IsViewCommit -}} + {{- /* for /owner/repo/src/commit/000000 */ -}} + {{- $branchDropdownCurrentRefType = "commit" -}} + {{- $branchDropdownCurrentRefShortName = ShortSha .ctxData.CommitID -}} +{{- end -}} {{template "repo/branch_dropdown" dict "Repository" .ctxData.Repository "ShowTabBranches" true diff --git a/templates/repo/view_file_tree_sidebar.tmpl b/templates/repo/view_file_tree_sidebar.tmpl index f52e17fdef..0c9e1816d1 100644 --- a/templates/repo/view_file_tree_sidebar.tmpl +++ b/templates/repo/view_file_tree_sidebar.tmpl @@ -1,9 +1,15 @@ -{{$branchDropdownCurrentRefType := "branch"}} -{{$branchDropdownCurrentRefShortName := .BranchName}} -{{if .IsViewTag}} - {{$branchDropdownCurrentRefType = "tag"}} - {{$branchDropdownCurrentRefShortName = .TagName}} -{{end}} +{{- /* for repo home (default branch) and /owner/repo/src/branch/the-name */ -}} +{{- $branchDropdownCurrentRefType := "branch" -}} +{{- $branchDropdownCurrentRefShortName := .BranchName -}} +{{- if .IsViewTag -}} + {{- /* for /owner/repo/src/tag/the-name */ -}} + {{- $branchDropdownCurrentRefType = "tag" -}} + {{- $branchDropdownCurrentRefShortName = .TagName -}} +{{- else if .IsViewCommit -}} + {{- /* for /owner/repo/src/commit/000000 */ -}} + {{- $branchDropdownCurrentRefType = "commit" -}} + {{- $branchDropdownCurrentRefShortName = ShortSha .CommitID -}} +{{- end -}}