mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 02:08:36 +00:00
Allow maintainers to view and edit files of private repos when "Allow maintainers to edit" is enabled (#32215)
Fix #31539
This commit is contained in:
@@ -374,7 +374,7 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
|
||||
return
|
||||
}
|
||||
|
||||
if !ctx.Repo.Permission.HasAnyUnitAccessOrEveryoneAccess() {
|
||||
if !ctx.Repo.Permission.HasAnyUnitAccessOrEveryoneAccess() && !canWriteAsMaintainer(ctx) {
|
||||
if ctx.FormString("go-get") == "1" {
|
||||
EarlyResponseForGoGetMeta(ctx)
|
||||
return
|
||||
@@ -1058,3 +1058,11 @@ func GitHookService() func(ctx *Context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// canWriteAsMaintainer check if the doer can write to a branch as a maintainer
|
||||
func canWriteAsMaintainer(ctx *Context) bool {
|
||||
branchName := getRefNameFromPath(ctx.Repo, ctx.PathParam("*"), func(branchName string) bool {
|
||||
return issues_model.CanMaintainerWriteToBranch(ctx, ctx.Repo.Permission, branchName, ctx.Doer)
|
||||
})
|
||||
return len(branchName) > 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user