diff options
Diffstat (limited to 'routers/web/repo/compare.go')
-rw-r--r-- | routers/web/repo/compare.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index 555abc1c8b..86ecc2bab1 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -17,6 +17,7 @@ import ( "strings" "code.gitea.io/gitea/models" + "code.gitea.io/gitea/models/unit" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/charset" "code.gitea.io/gitea/modules/context" @@ -384,7 +385,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo { ctx.ServerError("GetUserRepoPermission", err) return nil } - if !permBase.CanRead(models.UnitTypeCode) { + if !permBase.CanRead(unit.TypeCode) { if log.IsTrace() { log.Trace("Permission Denied: User: %-v cannot read code in Repo: %-v\nUser in baseRepo has Permissions: %-+v", ctx.User, @@ -403,7 +404,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo { ctx.ServerError("GetUserRepoPermission", err) return nil } - if !permHead.CanRead(models.UnitTypeCode) { + if !permHead.CanRead(unit.TypeCode) { if log.IsTrace() { log.Trace("Permission Denied: User: %-v cannot read code in Repo: %-v\nUser in headRepo has Permissions: %-+v", ctx.User, @@ -422,7 +423,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo { if rootRepo != nil && rootRepo.ID != ci.HeadRepo.ID && rootRepo.ID != baseRepo.ID { - canRead := rootRepo.CheckUnitUser(ctx.User, models.UnitTypeCode) + canRead := rootRepo.CheckUnitUser(ctx.User, unit.TypeCode) if canRead { ctx.Data["RootRepo"] = rootRepo if !fileOnly { @@ -447,7 +448,7 @@ func ParseCompareInfo(ctx *context.Context) *CompareInfo { ownForkRepo.ID != ci.HeadRepo.ID && ownForkRepo.ID != baseRepo.ID && (rootRepo == nil || ownForkRepo.ID != rootRepo.ID) { - canRead := ownForkRepo.CheckUnitUser(ctx.User, models.UnitTypeCode) + canRead := ownForkRepo.CheckUnitUser(ctx.User, unit.TypeCode) if canRead { ctx.Data["OwnForkRepo"] = ownForkRepo if !fileOnly { @@ -542,7 +543,7 @@ func PrepareCompareDiff( if (headCommitID == ci.CompareInfo.MergeBase && !ci.DirectComparison) || headCommitID == ci.CompareInfo.BaseCommitID { ctx.Data["IsNothingToCompare"] = true - if unit, err := repo.GetUnit(models.UnitTypePullRequests); err == nil { + if unit, err := repo.GetUnit(unit.TypePullRequests); err == nil { config := unit.PullRequestsConfig() if !config.AutodetectManualMerge { @@ -736,7 +737,7 @@ func CompareDiff(ctx *context.Context) { ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled upload.AddUploadContext(ctx, "comment") - ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWrite(models.UnitTypePullRequests) + ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWrite(unit.TypePullRequests) ctx.HTML(http.StatusOK, tplCompare) } |