1
1
mirror of https://github.com/go-gitea/gitea synced 2025-01-19 06:04:26 +00:00

Fix branch dropdown not display ref name (#33159)

Before:

![image](https://github.com/user-attachments/assets/899d25a9-80e9-48d5-a820-79c911c858e9)
After:

![image](https://github.com/user-attachments/assets/cf2a7407-909a-41db-9957-19d9214af57e)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
yp05327 2025-01-10 03:43:49 +09:00 committed by GitHub
parent 5f679c1c59
commit 2298ff2152
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 20 deletions

View File

@ -1,8 +1,8 @@
{{/* Attributes: {{/* Attributes:
* ContainerClasses * ContainerClasses
* Repository * Repository
* CurrentRefType: eg. "branch", "tag" * CurrentRefType: eg. "branch", "tag", "commit"
* CurrentRefShortName: eg. "master", "v1.0" * CurrentRefShortName: eg. "master", "v1.0", "abcdef0123"
* CurrentTreePath * CurrentTreePath
* RefLinkTemplate: redirect to the link when a branch/tag is selected * RefLinkTemplate: redirect to the link when a branch/tag is selected
* RefFormActionTemplate: change the parent form's action when a branch/tag is selected * RefFormActionTemplate: change the parent form's action when a branch/tag is selected

View File

@ -5,14 +5,19 @@
{{template "repo/sub_menu" .}} {{template "repo/sub_menu" .}}
<div class="repo-button-row"> <div class="repo-button-row">
<div class="repo-button-row-left"> <div class="repo-button-row-left">
{{- /* for /owner/repo/commits/branch/the-name */ -}}
{{$branchDropdownCurrentRefType := "branch"}} {{- $branchDropdownCurrentRefType := "branch" -}}
{{$branchDropdownCurrentRefShortName := .BranchName}} {{- $branchDropdownCurrentRefShortName := .BranchName -}}
{{if .IsViewTag}} {{- if .IsViewTag -}}
{{$branchDropdownCurrentRefType = "tag"}} {{- /* for /owner/repo/commits/tag/the-name */ -}}
{{$branchDropdownCurrentRefShortName = .TagName}} {{- $branchDropdownCurrentRefType = "tag" -}}
{{end}} {{- $branchDropdownCurrentRefShortName = .TagName -}}
{{template "repo/branch_dropdown" dict {{- else if .IsViewCommit -}}
{{- /* for /owner/repo/commits/commit/000000 */ -}}
{{- $branchDropdownCurrentRefType = "commit" -}}
{{- $branchDropdownCurrentRefShortName = ShortSha .CommitID -}}
{{- end -}}
{{- template "repo/branch_dropdown" dict
"Repository" .Repository "Repository" .Repository
"ShowTabBranches" true "ShowTabBranches" true
"ShowTabTags" true "ShowTabTags" true
@ -21,8 +26,7 @@
"CurrentTreePath" .TreePath "CurrentTreePath" .TreePath
"RefLinkTemplate" "{RepoLink}/commits/{RefType}/{RefShortName}/{TreePath}" "RefLinkTemplate" "{RepoLink}/commits/{RefType}/{RefShortName}/{TreePath}"
"AllowCreateNewRef" .CanCreateBranch "AllowCreateNewRef" .CanCreateBranch
}} -}}
<a href="{{.RepoLink}}/graph" class="ui basic small compact button"> <a href="{{.RepoLink}}/graph" class="ui basic small compact button">
{{svg "octicon-git-branch"}} {{svg "octicon-git-branch"}}
{{ctx.Locale.Tr "repo.commit_graph"}} {{ctx.Locale.Tr "repo.commit_graph"}}

View File

@ -24,13 +24,19 @@
{{template "repo/sub_menu" .}} {{template "repo/sub_menu" .}}
<div class="repo-button-row"> <div class="repo-button-row">
<div class="repo-button-row-left"> <div class="repo-button-row-left">
{{$branchDropdownCurrentRefType := "branch"}} {{- /* for repo home (default branch) and /owner/repo/src/branch/the-name */ -}}
{{$branchDropdownCurrentRefShortName := .BranchName}} {{- $branchDropdownCurrentRefType := "branch" -}}
{{if .IsViewTag}} {{- $branchDropdownCurrentRefShortName := .BranchName -}}
{{$branchDropdownCurrentRefType = "tag"}} {{- if .IsViewTag -}}
{{$branchDropdownCurrentRefShortName = .TagName}} {{- /* for /owner/repo/src/tag/the-name */ -}}
{{end}} {{- $branchDropdownCurrentRefType = "tag" -}}
{{template "repo/branch_dropdown" dict {{- $branchDropdownCurrentRefShortName = .TagName -}}
{{- else if .IsViewCommit -}}
{{- /* for /owner/repo/src/commit/000000 */ -}}
{{- $branchDropdownCurrentRefType = "commit" -}}
{{- $branchDropdownCurrentRefShortName = ShortSha .CommitID -}}
{{- end -}}
{{- template "repo/branch_dropdown" dict
"Repository" .Repository "Repository" .Repository
"ShowTabBranches" true "ShowTabBranches" true
"ShowTabTags" true "ShowTabTags" true
@ -40,7 +46,7 @@
"RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}" "RefLinkTemplate" "{RepoLink}/src/{RefType}/{RefShortName}/{TreePath}"
"AllowCreateNewRef" .CanCreateBranch "AllowCreateNewRef" .CanCreateBranch
"ShowViewAllRefsEntry" true "ShowViewAllRefsEntry" true
}} -}}
{{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}} {{if and .CanCompareOrPull .IsViewBranch (not .Repository.IsArchived)}}
{{$cmpBranch := ""}} {{$cmpBranch := ""}}
{{if ne .Repository.ID .BaseRepo.ID}} {{if ne .Repository.ID .BaseRepo.ID}}