From df00089ea8c2b48b1a9fd0a97e28c6d348f8a016 Mon Sep 17 00:00:00 2001 From: zeripath Date: Mon, 4 Feb 2019 00:56:18 +0000 Subject: [PATCH] Issue 5924 fix compare button (#5929) * Revert #5877 This unfortunately was not the solution. Signed-off-by: Andrew Thornton * Change permission check to create pull requests to CanReadIssuesOrPulls Signed-off-by: Andrew Thornton --- routers/api/v1/repo/pull.go | 4 ++-- routers/repo/pull.go | 4 ++-- templates/repo/home.tmpl | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go index 2ad321ea38f9..64c7e9447453 100644 --- a/routers/api/v1/repo/pull.go +++ b/routers/api/v1/repo/pull.go @@ -668,8 +668,8 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption) ctx.ServerError("GetUserRepoPermission", err) return nil, nil, nil, nil, "", "" } - if !perm.CanWrite(models.UnitTypeCode) { - log.Trace("ParseCompareInfo[%d]: does not have write access or site admin", baseRepo.ID) + if !perm.CanReadIssuesOrPulls(true) { + log.Trace("ParseCompareInfo[%d]: cannot create/read pull requests", baseRepo.ID) ctx.Status(404) return nil, nil, nil, nil, "", "" } diff --git a/routers/repo/pull.go b/routers/repo/pull.go index f408948a1781..c4313bca0050 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -684,8 +684,8 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, * ctx.ServerError("GetUserRepoPermission", err) return nil, nil, nil, nil, "", "" } - if !perm.CanWrite(models.UnitTypeCode) { - log.Trace("ParseCompareInfo[%d]: does not have write access or site admin", baseRepo.ID) + if !perm.CanReadIssuesOrPulls(true) { + log.Trace("ParseCompareInfo[%d]: cannot create/read pull requests", baseRepo.ID) ctx.NotFound("ParseCompareInfo", nil) return nil, nil, nil, nil, "", "" } diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 15676e9912e9..769569ff2e85 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -54,7 +54,7 @@