blob: f158cda2f0ecac41b7cb22a1f4489fb7d3f9a2b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
module Ci
class BuildPolicy < CommitStatusPolicy
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
condition(:owner_of_build) do
can?(:developer_access) && @subject.owned_by?(@user)
end
rule { protected_ref }.prevent :update_build
rule { can?(:master_access) | owner_of_build }.enable :erase_build
end
end
|