diff --git a/templates/repo/branch_dropdown.tmpl b/templates/repo/branch_dropdown.tmpl index b68c34a02a..6efed3427f 100644 --- a/templates/repo/branch_dropdown.tmpl +++ b/templates/repo/branch_dropdown.tmpl @@ -1,8 +1,8 @@ {{/* Attributes: * ContainerClasses * Repository -* CurrentRefType: eg. "branch", "tag" -* CurrentRefShortName: eg. "master", "v1.0" +* CurrentRefType: eg. "branch", "tag", "commit" +* CurrentRefShortName: eg. "master", "v1.0", "abcdef0123" * CurrentTreePath * RefLinkTemplate: redirect to the link when a branch/tag is selected * RefFormActionTemplate: change the parent form's action when a branch/tag is selected diff --git a/templates/repo/commits.tmpl b/templates/repo/commits.tmpl index 7065bf33f4..d80d4ac276 100644 --- a/templates/repo/commits.tmpl +++ b/templates/repo/commits.tmpl @@ -5,14 +5,19 @@ {{template "repo/sub_menu" .}}
- - {{$branchDropdownCurrentRefType := "branch"}} - {{$branchDropdownCurrentRefShortName := .BranchName}} - {{if .IsViewTag}} - {{$branchDropdownCurrentRefType = "tag"}} - {{$branchDropdownCurrentRefShortName = .TagName}} - {{end}} - {{template "repo/branch_dropdown" dict + {{- /* for /owner/repo/commits/branch/the-name */ -}} + {{- $branchDropdownCurrentRefType := "branch" -}} + {{- $branchDropdownCurrentRefShortName := .BranchName -}} + {{- if .IsViewTag -}} + {{- /* for /owner/repo/commits/tag/the-name */ -}} + {{- $branchDropdownCurrentRefType = "tag" -}} + {{- $branchDropdownCurrentRefShortName = .TagName -}} + {{- else if .IsViewCommit -}} + {{- /* for /owner/repo/commits/commit/000000 */ -}} + {{- $branchDropdownCurrentRefType = "commit" -}} + {{- $branchDropdownCurrentRefShortName = ShortSha .CommitID -}} + {{- end -}} + {{- template "repo/branch_dropdown" dict "Repository" .Repository "ShowTabBranches" true "ShowTabTags" true @@ -21,8 +26,7 @@ "CurrentTreePath" .TreePath "RefLinkTemplate" "{RepoLink}/commits/{RefType}/{RefShortName}/{TreePath}" "AllowCreateNewRef" .CanCreateBranch - }} - + -}} {{svg "octicon-git-branch"}} {{ctx.Locale.Tr "repo.commit_graph"}} diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index d73b7470bc..f80c9c1f4b 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -24,13 +24,19 @@ {{template "repo/sub_menu" .}}
- {{$branchDropdownCurrentRefType := "branch"}} - {{$branchDropdownCurrentRefShortName := .BranchName}} - {{if .IsViewTag}} - {{$branchDropdownCurrentRefType = "tag"}} - {{$branchDropdownCurrentRefShortName = .TagName}} - {{end}} - {{template "repo/branch_dropdown" dict + {{- /* 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 -}} + {{- template "repo/branch_dropdown" dict "Repository" .Repository "ShowTabBranches" true "ShowTabTags" true @@ -40,7 +46,7 @@ "RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}" "AllowCreateNewRef" .CanCreateBranch "ShowViewAllRefsEntry" true - }} + -}} {{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}} {{$cmpBranch := ""}} {{if ne .Repository.ID .BaseRepo.ID}}