Skip to content

Commit fe99c99

Browse files
zeripathlafriks
authored andcommitted
Issue 5924 fix compare button (#5929) (#6098)
* Revert #5877 This unfortunately was not the solution. Signed-off-by: Andrew Thornton <[email protected]> * Change permission check to create pull requests to CanReadIssuesOrPulls Signed-off-by: Andrew Thornton <[email protected]>
1 parent 2e1540e commit fe99c99

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

routers/api/v1/repo/pull.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -668,8 +668,8 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
668668
ctx.ServerError("GetUserRepoPermission", err)
669669
return nil, nil, nil, nil, "", ""
670670
}
671-
if !perm.CanWrite(models.UnitTypeCode) {
672-
log.Trace("ParseCompareInfo[%d]: does not have write access or site admin", baseRepo.ID)
671+
if !perm.CanReadIssuesOrPulls(true) {
672+
log.Trace("ParseCompareInfo[%d]: cannot create/read pull requests", baseRepo.ID)
673673
ctx.Status(404)
674674
return nil, nil, nil, nil, "", ""
675675
}

routers/repo/pull.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -684,8 +684,8 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *
684684
ctx.ServerError("GetUserRepoPermission", err)
685685
return nil, nil, nil, nil, "", ""
686686
}
687-
if !perm.CanWrite(models.UnitTypeCode) {
688-
log.Trace("ParseCompareInfo[%d]: does not have write access or site admin", baseRepo.ID)
687+
if !perm.CanReadIssuesOrPulls(true) {
688+
log.Trace("ParseCompareInfo[%d]: cannot create/read pull requests", baseRepo.ID)
689689
ctx.NotFound("ParseCompareInfo", nil)
690690
return nil, nil, nil, nil, "", ""
691691
}

templates/repo/home.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
<div class="ui stackable secondary menu mobile--margin-between-items mobile--no-negative-margins">
5555
{{if and .PullRequestCtx.Allowed .IsViewBranch}}
5656
<div class="fitted item">
57-
<a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch | EscapePound}}...{{ if .Repository.IsFork }}{{.Repository.Owner.Name}}{{ else }}{{ .SignedUserName }}{{ end }}:{{.BranchName | EscapePound}}">
57+
<a href="{{.BaseRepo.Link}}/compare/{{.BaseRepo.DefaultBranch | EscapePound}}...{{if ne .Repository.Owner.Name .BaseRepo.Owner.Name}}{{.Repository.Owner.Name}}:{{end}}{{.BranchName | EscapePound}}">
5858
<button class="ui green tiny compact button"><i class="octicon octicon-git-compare"></i></button>
5959
</a>
6060
</div>

0 commit comments

Comments
 (0)