Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
42e7e750
Commit
42e7e750
authored
Sep 05, 2017
by
Maxim Rydkin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor app/services/ci/create_pipeline_service.rb:50:5
parent
0963ac36
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+14
-12
No files found.
app/services/ci/create_pipeline_service.rb
View file @
42e7e750
...
...
@@ -16,9 +16,9 @@ module Ci
protected:
project
.
protected_for?
(
ref
)
)
result
=
validate
(
current_user
,
ignore_skip_ci:
ignore_skip_ci
,
save_on_errors:
save_on_errors
)
result
=
validate
_project_and_git_items
||
validate_pipeline
(
ignore_skip_ci:
ignore_skip_ci
,
save_on_errors:
save_on_errors
)
return
result
if
result
...
...
@@ -47,13 +47,13 @@ module Ci
private
def
validate
(
triggering_user
,
ignore_skip_ci
:,
save_on_errors
:)
def
validate
_project_and_git_items
unless
project
.
builds_enabled?
return
error
(
'Pipeline is disabled'
)
end
unless
allowed_to_trigger_pipeline?
(
triggering_user
)
if
can?
(
triggering
_user
,
:create_pipeline
,
project
)
unless
allowed_to_trigger_pipeline?
if
can?
(
current
_user
,
:create_pipeline
,
project
)
return
error
(
"Insufficient permissions for protected ref '
#{
ref
}
'"
)
else
return
error
(
'Insufficient permissions to create a new pipeline'
)
...
...
@@ -67,7 +67,9 @@ module Ci
unless
commit
return
error
(
'Commit not found'
)
end
end
def
validate_pipeline
(
ignore_skip_ci
:,
save_on_errors
:)
unless
pipeline
.
config_processor
unless
pipeline
.
ci_yaml_file
return
error
(
"Missing
#{
pipeline
.
ci_yaml_file_path
}
file"
)
...
...
@@ -85,18 +87,18 @@ module Ci
end
end
def
allowed_to_trigger_pipeline?
(
triggering_user
)
if
triggering
_user
allowed_to_create?
(
triggering_user
)
def
allowed_to_trigger_pipeline?
if
current
_user
allowed_to_create?
else
# legacy triggers don't have a corresponding user
!
project
.
protected_for?
(
ref
)
end
end
def
allowed_to_create?
(
triggering_user
)
access
=
Gitlab
::
UserAccess
.
new
(
triggering
_user
,
project:
project
)
def
allowed_to_create?
access
=
Gitlab
::
UserAccess
.
new
(
current
_user
,
project:
project
)
can?
(
triggering
_user
,
:create_pipeline
,
project
)
&&
can?
(
current
_user
,
:create_pipeline
,
project
)
&&
if
branch?
access
.
can_update_branch?
(
ref
)
elsif
tag?
...
...
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