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
Tatuya Kamada
gitlab-ce
Commits
31be74c7
Commit
31be74c7
authored
Jan 25, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return struct instead of multiple values
parent
32347415
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
8 deletions
+10
-8
app/services/ci/register_build_service.rb
app/services/ci/register_build_service.rb
+4
-2
lib/ci/api/builds.rb
lib/ci/api/builds.rb
+5
-5
spec/services/ci/register_build_service_spec.rb
spec/services/ci/register_build_service_spec.rb
+1
-1
No files found.
app/services/ci/register_build_service.rb
View file @
31be74c7
...
@@ -6,6 +6,8 @@ module Ci
...
@@ -6,6 +6,8 @@ module Ci
attr_reader
:runner
attr_reader
:runner
Result
=
Struct
.
new
(
:build
,
:valid?
)
def
initialize
(
runner
)
def
initialize
(
runner
)
@runner
=
runner
@runner
=
runner
end
end
...
@@ -29,10 +31,10 @@ module Ci
...
@@ -29,10 +31,10 @@ module Ci
build
.
run!
build
.
run!
end
end
[
build
,
true
]
Result
.
new
(
build
,
true
)
rescue
StateMachines
::
InvalidTransition
,
ActiveRecord
::
StaleObjectError
rescue
StateMachines
::
InvalidTransition
,
ActiveRecord
::
StaleObjectError
[
nil
,
false
]
Result
.
new
(
build
,
false
)
end
end
private
private
...
...
lib/ci/api/builds.rb
View file @
31be74c7
...
@@ -24,14 +24,14 @@ module Ci
...
@@ -24,14 +24,14 @@ module Ci
new_update
=
current_runner
.
ensure_runner_queue_value
new_update
=
current_runner
.
ensure_runner_queue_value
build
,
valid
=
Ci
::
RegisterBuildService
.
new
(
current_runner
).
execute
result
=
Ci
::
RegisterBuildService
.
new
(
current_runner
).
execute
if
valid
if
result
.
valid?
if
build
if
result
.
build
Gitlab
::
Metrics
.
add_event
(
:build_found
,
Gitlab
::
Metrics
.
add_event
(
:build_found
,
project:
build
.
project
.
path_with_namespace
)
project:
result
.
build
.
project
.
path_with_namespace
)
present
build
,
with:
Entities
::
BuildDetails
present
result
.
build
,
with:
Entities
::
BuildDetails
else
else
Gitlab
::
Metrics
.
add_event
(
:build_not_found
)
Gitlab
::
Metrics
.
add_event
(
:build_not_found
)
...
...
spec/services/ci/register_build_service_spec.rb
View file @
31be74c7
...
@@ -171,7 +171,7 @@ module Ci
...
@@ -171,7 +171,7 @@ module Ci
end
end
def
execute
(
runner
)
def
execute
(
runner
)
described_class
.
new
(
runner
).
execute
.
first
described_class
.
new
(
runner
).
execute
.
build
end
end
end
end
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