BigW Consortium Gitlab

Commit 679789ee by Lin Jen-Shin

Rename can_push_or_merge_to_branch? to can_update_branch?

Also make sure pipeline would also check against tag as well
parent c86e74b2
...@@ -6,7 +6,7 @@ module Ci ...@@ -6,7 +6,7 @@ module Ci
if @subject.tag? if @subject.tag?
!access.can_create_tag?(@subject.ref) !access.can_create_tag?(@subject.ref)
else else
!access.can_push_or_merge_to_branch?(@subject.ref) !access.can_update_branch?(@subject.ref)
end end
end end
......
...@@ -3,9 +3,13 @@ module Ci ...@@ -3,9 +3,13 @@ module Ci
delegate { @subject.project } delegate { @subject.project }
condition(:user_cannot_update) do condition(:user_cannot_update) do
!::Gitlab::UserAccess access = ::Gitlab::UserAccess.new(@user, project: @subject.project)
.new(@user, project: @subject.project)
.can_push_or_merge_to_branch?(@subject.ref) if @subject.tag?
!access.can_create_tag?(@subject.ref)
else
!access.can_update_branch?(@subject.ref)
end
end end
rule { user_cannot_update }.prevent :update_pipeline rule { user_cannot_update }.prevent :update_pipeline
......
...@@ -89,7 +89,7 @@ module Ci ...@@ -89,7 +89,7 @@ module Ci
Ability.allowed?(triggering_user, :create_pipeline, project) && Ability.allowed?(triggering_user, :create_pipeline, project) &&
if branch? if branch?
access.can_push_or_merge_to_branch?(ref) access.can_update_branch?(ref)
elsif tag? elsif tag?
access.can_create_tag?(ref) access.can_create_tag?(ref)
else else
......
...@@ -54,7 +54,7 @@ module Gitlab ...@@ -54,7 +54,7 @@ module Gitlab
end end
end end
def can_push_or_merge_to_branch?(ref) def can_update_branch?(ref)
can_push_to_branch?(ref) || can_merge_to_branch?(ref) can_push_to_branch?(ref) || can_merge_to_branch?(ref)
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment