Welcome to mirror list, hosted at ThFree Co, Russian Federation.

pipeline_policy.rb « ci « policies « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 07d724c9cfdcc2371bf3156a26d3531ab1dc6c91 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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