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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
1c7871e9
Commit
1c7871e9
authored
Jul 14, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce get_build! so we could omit one early return
parent
fab8bc53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
14 deletions
+12
-14
lib/api/builds.rb
lib/api/builds.rb
+12
-14
No files found.
lib/api/builds.rb
View file @
1c7871e9
...
@@ -52,8 +52,7 @@ module API
...
@@ -52,8 +52,7 @@ module API
get
':id/builds/:build_id'
do
get
':id/builds/:build_id'
do
authorize_read_builds!
authorize_read_builds!
build
=
get_build
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
present
build
,
with:
Entities
::
Build
,
present
build
,
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
...
@@ -69,8 +68,7 @@ module API
...
@@ -69,8 +68,7 @@ module API
get
':id/builds/:build_id/artifacts'
do
get
':id/builds/:build_id/artifacts'
do
authorize_read_builds!
authorize_read_builds!
build
=
get_build
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
artifacts_file
=
build
.
artifacts_file
artifacts_file
=
build
.
artifacts_file
...
@@ -97,8 +95,7 @@ module API
...
@@ -97,8 +95,7 @@ module API
get
':id/builds/:build_id/trace'
do
get
':id/builds/:build_id/trace'
do
authorize_read_builds!
authorize_read_builds!
build
=
get_build
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
header
'Content-Disposition'
,
"infile; filename=
\"
#{
build
.
id
}
.log
\"
"
header
'Content-Disposition'
,
"infile; filename=
\"
#{
build
.
id
}
.log
\"
"
content_type
'text/plain'
content_type
'text/plain'
...
@@ -118,8 +115,7 @@ module API
...
@@ -118,8 +115,7 @@ module API
post
':id/builds/:build_id/cancel'
do
post
':id/builds/:build_id/cancel'
do
authorize_update_builds!
authorize_update_builds!
build
=
get_build
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
build
.
cancel
build
.
cancel
...
@@ -137,8 +133,7 @@ module API
...
@@ -137,8 +133,7 @@ module API
post
':id/builds/:build_id/retry'
do
post
':id/builds/:build_id/retry'
do
authorize_update_builds!
authorize_update_builds!
build
=
get_build
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
return
forbidden!
(
'Build is not retryable'
)
unless
build
.
retryable?
return
forbidden!
(
'Build is not retryable'
)
unless
build
.
retryable?
build
=
Ci
::
Build
.
retry
(
build
,
current_user
)
build
=
Ci
::
Build
.
retry
(
build
,
current_user
)
...
@@ -157,8 +152,7 @@ module API
...
@@ -157,8 +152,7 @@ module API
post
':id/builds/:build_id/erase'
do
post
':id/builds/:build_id/erase'
do
authorize_update_builds!
authorize_update_builds!
build
=
get_build
(
params
[
:build_id
])
build
=
get_build!
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
return
forbidden!
(
'Build is not erasable!'
)
unless
build
.
erasable?
return
forbidden!
(
'Build is not erasable!'
)
unless
build
.
erasable?
build
.
erase
(
erased_by:
current_user
)
build
.
erase
(
erased_by:
current_user
)
...
@@ -176,8 +170,8 @@ module API
...
@@ -176,8 +170,8 @@ module API
post
':id/builds/:build_id/artifacts/keep'
do
post
':id/builds/:build_id/artifacts/keep'
do
authorize_update_builds!
authorize_update_builds!
build
=
get_build
(
params
[
:build_id
])
build
=
get_build
!
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
&&
build
.
artifacts?
return
not_found!
(
build
)
unless
build
.
artifacts?
build
.
keep_artifacts!
build
.
keep_artifacts!
...
@@ -192,6 +186,10 @@ module API
...
@@ -192,6 +186,10 @@ module API
user_project
.
builds
.
find_by
(
id:
id
.
to_i
)
user_project
.
builds
.
find_by
(
id:
id
.
to_i
)
end
end
def
get_build!
(
id
)
get_build
(
id
)
||
not_found!
end
def
filter_builds
(
builds
,
scope
)
def
filter_builds
(
builds
,
scope
)
return
builds
if
scope
.
nil?
||
scope
.
empty?
return
builds
if
scope
.
nil?
||
scope
.
empty?
...
...
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