Commit 36cac35b24d7b8318de40bd2e495b8807eef48fc
1 parent
a9d60b3b
Exists in
spb-stable
and in
2 other branches
Dont allow remove of protected branch
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Showing
1 changed file
with
12 additions
and
8 deletions
Show diff stats
lib/gitlab/git_access.rb
... | ... | @@ -44,14 +44,18 @@ module Gitlab |
44 | 44 | def push_allowed?(user, project, ref, oldrev, newrev, forced_push) |
45 | 45 | if user && user_allowed?(user) |
46 | 46 | action = if project.protected_branch?(ref) |
47 | - if forced_push.to_s == 'true' | |
48 | - :force_push_code_to_protected_branches | |
49 | - else | |
50 | - :push_code_to_protected_branches | |
51 | - end | |
52 | - else | |
53 | - :push_code | |
54 | - end | |
47 | + # we dont allow force push to protected branch | |
48 | + if forced_push.to_s == 'true' | |
49 | + :force_push_code_to_protected_branches | |
50 | + # and we dont allow remove of protected branch | |
51 | + elsif newrev =~ /0000000/ | |
52 | + :remove_protected_branches | |
53 | + else | |
54 | + :push_code_to_protected_branches | |
55 | + end | |
56 | + else | |
57 | + :push_code | |
58 | + end | |
55 | 59 | user.can?(action, project) |
56 | 60 | else |
57 | 61 | false | ... | ... |