Skip to content

Commit e4eb070

Browse files
committed
ui: branch list: use the new Compare language when available
When viewing the branch listing as an unauthenticated user, you'll get "Pull Request" buttons. use the new "Compare" verbiage instead, which matches GitHub behavior when you can't issue a pull request from the branches.
1 parent 565ef1f commit e4eb070

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

routers/repo/branch.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ func Branches(ctx *context.Context) {
4646
ctx.Data["AllowsPulls"] = ctx.Repo.Repository.AllowsPulls()
4747
ctx.Data["IsWriter"] = ctx.Repo.CanWrite(models.UnitTypeCode)
4848
ctx.Data["IsMirror"] = ctx.Repo.Repository.IsMirror
49+
ctx.Data["CanPull"] = ctx.Repo.CanWrite(models.UnitTypeCode) || (ctx.IsSigned && ctx.User.HasForkedRepo(ctx.Repo.Repository.ID))
4950
ctx.Data["PageIsViewCode"] = true
5051
ctx.Data["PageIsBranches"] = true
5152

templates/repo/branch/list.tmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@
8181
</a>
8282
{{else if and (not .IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}}
8383
<a href="{{$.RepoLink}}/compare/{{$.DefaultBranch | EscapePound}}...{{if ne $.Repository.Owner.Name $.Owner.Name}}{{$.Owner.Name}}:{{end}}{{.Name | EscapePound}}">
84-
<button id="new-pull-request" class="ui compact basic button">{{$.i18n.Tr "repo.pulls.compare_changes"}}</button>
84+
<button id="new-pull-request" class="ui compact basic button">{{if $.CanPull}}{{$.i18n.Tr "repo.pulls.compare_changes"}}{{else}}{{$.i18n.Tr "action.compare_branch"}}{{end}}</button>
8585
</a>
8686
{{end}}
8787
{{else if and .LatestPullRequest.HasMerged .MergeMovedOn}}
8888
{{if and (not .IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}}
8989
<a href="{{$.RepoLink}}/compare/{{$.DefaultBranch | EscapePound}}...{{if ne $.Repository.Owner.Name $.Owner.Name}}{{$.Owner.Name}}:{{end}}{{.Name | EscapePound}}">
90-
<button id="new-pull-request" class="ui compact basic button">{{$.i18n.Tr "repo.pulls.compare_changes"}}</button>
90+
<button id="new-pull-request" class="ui compact basic button">{{if $.CanPull}}{{$.i18n.Tr "repo.pulls.compare_changes"}}{{else}}{{$.i18n.Tr "action.compare_branch"}}{{end}}</button>
9191
</a>
9292
{{end}}
9393
{{else}}

0 commit comments

Comments
 (0)