aboutsummaryrefslogtreecommitdiffstats
path: root/modules/repofiles/update.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/repofiles/update.go')
-rw-r--r--modules/repofiles/update.go32
1 files changed, 21 insertions, 11 deletions
diff --git a/modules/repofiles/update.go b/modules/repofiles/update.go
index e2aafb567d..86f53d4a1c 100644
--- a/modules/repofiles/update.go
+++ b/modules/repofiles/update.go
@@ -156,21 +156,31 @@ func CreateOrUpdateRepoFile(repo *models.Repository, doer *models.User, opts *Up
if err != nil {
return nil, err
}
- if protectedBranch != nil && !protectedBranch.CanUserPush(doer.ID) {
- return nil, models.ErrUserCannotCommit{
- UserName: doer.LowerName,
- }
- }
- if protectedBranch != nil && protectedBranch.RequireSignedCommits {
- _, _, err := repo.SignCRUDAction(doer, repo.RepoPath(), opts.OldBranch)
- if err != nil {
- if !models.IsErrWontSign(err) {
- return nil, err
- }
+ if protectedBranch != nil {
+ if !protectedBranch.CanUserPush(doer.ID) {
return nil, models.ErrUserCannotCommit{
UserName: doer.LowerName,
}
}
+ if protectedBranch.RequireSignedCommits {
+ _, _, err := repo.SignCRUDAction(doer, repo.RepoPath(), opts.OldBranch)
+ if err != nil {
+ if !models.IsErrWontSign(err) {
+ return nil, err
+ }
+ return nil, models.ErrUserCannotCommit{
+ UserName: doer.LowerName,
+ }
+ }
+ }
+ patterns := protectedBranch.GetProtectedFilePatterns()
+ for _, pat := range patterns {
+ if pat.Match(strings.ToLower(opts.TreePath)) {
+ return nil, models.ErrFilePathProtected{
+ Path: opts.TreePath,
+ }
+ }
+ }
}
}