BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
679789ee
Commit
679789ee
authored
Jul 18, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename can_push_or_merge_to_branch? to can_update_branch?
Also make sure pipeline would also check against tag as well
parent
c86e74b2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
6 deletions
+10
-6
build_policy.rb
app/policies/ci/build_policy.rb
+1
-1
pipeline_policy.rb
app/policies/ci/pipeline_policy.rb
+7
-3
create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+1
-1
user_access.rb
lib/gitlab/user_access.rb
+1
-1
No files found.
app/policies/ci/build_policy.rb
View file @
679789ee
...
@@ -6,7 +6,7 @@ module Ci
...
@@ -6,7 +6,7 @@ module Ci
if
@subject
.
tag?
if
@subject
.
tag?
!
access
.
can_create_tag?
(
@subject
.
ref
)
!
access
.
can_create_tag?
(
@subject
.
ref
)
else
else
!
access
.
can_
push_or_merge_to
_branch?
(
@subject
.
ref
)
!
access
.
can_
update
_branch?
(
@subject
.
ref
)
end
end
end
end
...
...
app/policies/ci/pipeline_policy.rb
View file @
679789ee
...
@@ -3,9 +3,13 @@ module Ci
...
@@ -3,9 +3,13 @@ module Ci
delegate
{
@subject
.
project
}
delegate
{
@subject
.
project
}
condition
(
:user_cannot_update
)
do
condition
(
:user_cannot_update
)
do
!::
Gitlab
::
UserAccess
access
=
::
Gitlab
::
UserAccess
.
new
(
@user
,
project:
@subject
.
project
)
.
new
(
@user
,
project:
@subject
.
project
)
.
can_push_or_merge_to_branch?
(
@subject
.
ref
)
if
@subject
.
tag?
!
access
.
can_create_tag?
(
@subject
.
ref
)
else
!
access
.
can_update_branch?
(
@subject
.
ref
)
end
end
end
rule
{
user_cannot_update
}.
prevent
:update_pipeline
rule
{
user_cannot_update
}.
prevent
:update_pipeline
...
...
app/services/ci/create_pipeline_service.rb
View file @
679789ee
...
@@ -89,7 +89,7 @@ module Ci
...
@@ -89,7 +89,7 @@ module Ci
Ability
.
allowed?
(
triggering_user
,
:create_pipeline
,
project
)
&&
Ability
.
allowed?
(
triggering_user
,
:create_pipeline
,
project
)
&&
if
branch?
if
branch?
access
.
can_
push_or_merge_to
_branch?
(
ref
)
access
.
can_
update
_branch?
(
ref
)
elsif
tag?
elsif
tag?
access
.
can_create_tag?
(
ref
)
access
.
can_create_tag?
(
ref
)
else
else
...
...
lib/gitlab/user_access.rb
View file @
679789ee
...
@@ -54,7 +54,7 @@ module Gitlab
...
@@ -54,7 +54,7 @@ module Gitlab
end
end
end
end
def
can_
push_or_merge_to
_branch?
(
ref
)
def
can_
update
_branch?
(
ref
)
can_push_to_branch?
(
ref
)
||
can_merge_to_branch?
(
ref
)
can_push_to_branch?
(
ref
)
||
can_merge_to_branch?
(
ref
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment