Skip to content

Commit 0651cce

Browse files
committed
Fix bug
1 parent aa5d3bc commit 0651cce

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

services/context/permission.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func RequireRepoWriterOr(unitTypes ...unit.Type) func(ctx *Context) {
5858
func RequireRepoReader(unitType unit.Type) func(ctx *Context) {
5959
return func(ctx *Context) {
6060
if !ctx.Repo.CanRead(unitType) {
61-
if unitType == unit.TypeCode && canWriteAsMaintainer(ctx) {
61+
if unitType == unit.TypeCode && canWriteAsMaintainer(ctx, ctx.Repo.Repository.ID) {
6262
return
6363
}
6464
if log.IsTrace() {

services/context/repo.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
371371
return
372372
}
373373

374-
if !ctx.Repo.Permission.HasAnyUnitAccessOrEveryoneAccess() && !canWriteAsMaintainer(ctx) {
374+
if !ctx.Repo.Permission.HasAnyUnitAccessOrEveryoneAccess() && !canWriteAsMaintainer(ctx, repo.ID) {
375375
if ctx.FormString("go-get") == "1" {
376376
EarlyResponseForGoGetMeta(ctx)
377377
return
@@ -1025,9 +1025,9 @@ func GitHookService() func(ctx *Context) {
10251025
}
10261026

10271027
// canWriteAsMaintainer check if the doer can write to a branch as a maintainer
1028-
func canWriteAsMaintainer(ctx *Context) bool {
1028+
func canWriteAsMaintainer(ctx *Context, repoID int64) bool {
10291029
branchName := getRefNameFromPath(ctx.Repo, ctx.PathParam("*"), func(branchName string) bool {
1030-
return issues_model.CanMaintainerWriteToHeadBranch(ctx, ctx.Repo.Repository.ID, branchName, ctx.Doer)
1030+
return issues_model.CanMaintainerWriteToHeadBranch(ctx, repoID, branchName, ctx.Doer)
10311031
})
10321032
return len(branchName) > 0
10331033
}

0 commit comments

Comments
 (0)