diff options
author | Phil Hughes <me@iamphill.com> | 2017-08-02 18:37:40 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-08-02 18:37:40 +0300 |
commit | e4c20cd3fe330faa415493ee2fe30dc16fbaca80 (patch) | |
tree | 0be61b6cc59cf35d81b9271c7603e0d8b203a31c /app/policies/ci/pipeline_policy.rb | |
parent | 25d6a6c4b528159c288995de4909e6a8da431d0b (diff) | |
parent | 88958e5a9cd364ae36f3d2837982cedb9239c3bc (diff) |
Merge branch 'master' into sidebar-fly-out-sub-nav
Diffstat (limited to 'app/policies/ci/pipeline_policy.rb')
-rw-r--r-- | app/policies/ci/pipeline_policy.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/policies/ci/pipeline_policy.rb b/app/policies/ci/pipeline_policy.rb index a2dde95dbc8..4e689a9efd5 100644 --- a/app/policies/ci/pipeline_policy.rb +++ b/app/policies/ci/pipeline_policy.rb @@ -1,5 +1,17 @@ module Ci class PipelinePolicy < BasePolicy delegate { @subject.project } + + condition(:protected_ref) 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 { protected_ref }.prevent :update_pipeline end end |