debian-mirror-gitlab/app/policies/ci/build_policy.rb

25 lines
586 B
Ruby
Raw Normal View History

2016-09-29 09:46:39 +05:30
module Ci
class BuildPolicy < CommitStatusPolicy
2017-09-10 17:25:29 +05:30
condition(:protected_ref) do
access = ::Gitlab::UserAccess.new(@user, project: @subject.project)
2017-08-17 22:00:37 +05:30
2017-09-10 17:25:29 +05:30
if @subject.tag?
!access.can_create_tag?(@subject.ref)
else
!access.can_update_branch?(@subject.ref)
2017-08-17 22:00:37 +05:30
end
end
2018-03-17 18:26:18 +05:30
condition(:owner_of_job) do
2018-05-09 12:01:36 +05:30
@subject.triggered_by?(@user)
2018-03-17 18:26:18 +05:30
end
rule { protected_ref }.policy do
prevent :update_build
prevent :erase_build
end
2018-05-09 12:01:36 +05:30
rule { can?(:admin_build) | (can?(:update_build) & owner_of_job) }.enable :erase_build
2016-09-29 09:46:39 +05:30
end
end