summaryrefslogtreecommitdiffstats
path: root/services/repository/files/patch.go
diff options
context:
space:
mode:
Diffstat (limited to 'services/repository/files/patch.go')
-rw-r--r--services/repository/files/patch.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/services/repository/files/patch.go b/services/repository/files/patch.go
index 33f4b6c9dc..73ee0fa815 100644
--- a/services/repository/files/patch.go
+++ b/services/repository/files/patch.go
@@ -66,13 +66,16 @@ func (opts *ApplyDiffPatchOptions) Validate(ctx context.Context, repo *repo_mode
return err
}
} else {
- protectedBranch, err := git_model.GetProtectedBranchBy(ctx, repo.ID, opts.OldBranch)
+ protectedBranch, err := git_model.GetFirstMatchProtectedBranchRule(ctx, repo.ID, opts.OldBranch)
if err != nil {
return err
}
- if protectedBranch != nil && !protectedBranch.CanUserPush(ctx, doer.ID) {
- return models.ErrUserCannotCommit{
- UserName: doer.LowerName,
+ if protectedBranch != nil {
+ protectedBranch.Repo = repo
+ if !protectedBranch.CanUserPush(ctx, doer) {
+ return models.ErrUserCannotCommit{
+ UserName: doer.LowerName,
+ }
}
}
if protectedBranch != nil && protectedBranch.RequireSignedCommits {