gitlab-org--gitlab-foss/app/policies/ci/pipeline_policy.rb
Lin Jen-Shin 679789ee93 Rename can_push_or_merge_to_branch? to can_update_branch?
Also make sure pipeline would also check against tag as well
2017-07-18 21:56:28 +08:00

17 lines
409 B
Ruby

module Ci
class PipelinePolicy < BasePolicy
delegate { @subject.project }
condition(:user_cannot_update) do
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
end
end