1
0
Fork 0
forked from forgejo/forgejo

Add config option to disable "Update branch by rebase" (#18745)

This commit is contained in:
Jimmy Praet 2022-03-04 09:30:49 +01:00 committed by GitHub
parent 3c7201682c
commit 5184c83f6b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 31 additions and 2 deletions

View file

@ -10,6 +10,7 @@ import (
"code.gitea.io/gitea/models"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
@ -97,7 +98,12 @@ func IsUserAllowedToUpdate(pull *models.PullRequest, user *user_model.User) (mer
// can't do rebase on protected branch because need force push
if pr.ProtectedBranch == nil {
rebaseAllowed = true
prUnit, err := pr.BaseRepo.GetUnit(unit.TypePullRequests)
if err != nil {
log.Error("pr.BaseRepo.GetUnit(unit.TypePullRequests): %v", err)
return false, false, err
}
rebaseAllowed = prUnit.PullRequestsConfig().AllowRebaseUpdate
}
// Update function need push permission