Commit 679789ee authored by Lin Jen-Shin's avatar 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
if @subject.tag?
!access.can_create_tag?(@subject.ref)
else
!access.can_push_or_merge_to_branch?(@subject.ref)
!access.can_update_branch?(@subject.ref)
end
end
......
......@@ -3,9 +3,13 @@ module Ci
delegate { @subject.project }
condition(:user_cannot_update) do
!::Gitlab::UserAccess
.new(@user, project: @subject.project)
.can_push_or_merge_to_branch?(@subject.ref)
access = ::Gitlab::UserAccess.new(@user, project: @subject.project)
if @subject.tag?
!access.can_create_tag?(@subject.ref)
else
!access.can_update_branch?(@subject.ref)
end
end
rule { user_cannot_update }.prevent :update_pipeline
......
......@@ -89,7 +89,7 @@ module Ci
Ability.allowed?(triggering_user, :create_pipeline, project) &&
if branch?
access.can_push_or_merge_to_branch?(ref)
access.can_update_branch?(ref)
elsif tag?
access.can_create_tag?(ref)
else
......
......@@ -54,7 +54,7 @@ module Gitlab
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)
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