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
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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
14 deletions
+12
-14
builds.rb
lib/api/builds.rb
+12
-14
No files found.
lib/api/builds.rb
View file @
1c7871e9
...
...
@@ -52,8 +52,7 @@ module API
get
':id/builds/:build_id'
do
authorize_read_builds!
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
build
=
get_build!
(
params
[
:build_id
])
present
build
,
with:
Entities
::
Build
,
user_can_download_artifacts:
can?
(
current_user
,
:read_build
,
user_project
)
...
...
@@ -69,8 +68,7 @@ module API
get
':id/builds/:build_id/artifacts'
do
authorize_read_builds!
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
build
=
get_build!
(
params
[
:build_id
])
artifacts_file
=
build
.
artifacts_file
...
...
@@ -97,8 +95,7 @@ module API
get
':id/builds/:build_id/trace'
do
authorize_read_builds!
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
build
=
get_build!
(
params
[
:build_id
])
header
'Content-Disposition'
,
"infile; filename=
\"
#{
build
.
id
}
.log
\"
"
content_type
'text/plain'
...
...
@@ -118,8 +115,7 @@ module API
post
':id/builds/:build_id/cancel'
do
authorize_update_builds!
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
build
=
get_build!
(
params
[
:build_id
])
build
.
cancel
...
...
@@ -137,8 +133,7 @@ module API
post
':id/builds/:build_id/retry'
do
authorize_update_builds!
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
build
=
get_build!
(
params
[
:build_id
])
return
forbidden!
(
'Build is not retryable'
)
unless
build
.
retryable?
build
=
Ci
::
Build
.
retry
(
build
,
current_user
)
...
...
@@ -157,8 +152,7 @@ module API
post
':id/builds/:build_id/erase'
do
authorize_update_builds!
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
build
=
get_build!
(
params
[
:build_id
])
return
forbidden!
(
'Build is not erasable!'
)
unless
build
.
erasable?
build
.
erase
(
erased_by:
current_user
)
...
...
@@ -176,8 +170,8 @@ module API
post
':id/builds/:build_id/artifacts/keep'
do
authorize_update_builds!
build
=
get_build
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
&&
build
.
artifacts?
build
=
get_build
!
(
params
[
:build_id
])
return
not_found!
(
build
)
unless
build
.
artifacts?
build
.
keep_artifacts!
...
...
@@ -192,6 +186,10 @@ module API
user_project
.
builds
.
find_by
(
id:
id
.
to_i
)
end
def
get_build!
(
id
)
get_build
(
id
)
||
not_found!
end
def
filter_builds
(
builds
,
scope
)
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