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
iv
gitlab-ce
Commits
8c93b605
Commit
8c93b605
authored
May 14, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert `stages` change
parent
a6b8d36a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
4 deletions
+22
-4
app/models/commit_status.rb
app/models/commit_status.rb
+8
-3
app/views/projects/ci/commits/_commit.html.haml
app/views/projects/ci/commits/_commit.html.haml
+2
-1
spec/models/commit_status_spec.rb
spec/models/commit_status_spec.rb
+12
-0
No files found.
app/models/commit_status.rb
View file @
8c93b605
...
...
@@ -55,11 +55,16 @@ class CommitStatus < ActiveRecord::Base
def
self
.
stages
# We group by stage name, but order stages by theirs' index
unscoped
.
where
(
id:
all
.
ids
).
group
(
'stage'
).
order
(
'max(stage_idx)'
,
'stage'
).
pluck
(
'
stage'
)
unscoped
.
from
(
all
,
:sg
).
group
(
'stage'
).
order
(
'max(stage_idx)'
,
'stage'
).
pluck
(
'sg.
stage'
)
end
def
self
.
status_for_stage
(
stage
)
where
(
stage:
stage
).
status
def
self
.
stages_status
# We execute subquery for each stage to calculate a stage status
statuses
=
unscoped
.
from
(
all
,
:sg
).
group
(
'stage'
).
pluck
(
'sg.stage'
,
all
.
where
(
'stage=sg.stage'
).
status_sql
)
statuses
.
inject
({})
do
|
h
,
k
|
h
[
k
.
first
]
=
k
.
last
h
end
end
def
ignored?
...
...
app/views/projects/ci/commits/_commit.html.haml
View file @
8c93b605
...
...
@@ -31,9 +31,10 @@
Cant find HEAD commit for this branch
-
stages_status
=
commit
.
statuses
.
stages_status
-
stages
.
each
do
|
stage
|
%td
-
if
status
=
commit
.
statuses
.
status_for_stage
(
stage
)
-
if
status
=
stages_status
[
stage
]
-
tooltip
=
"
#{
stage
.
titleize
}
:
#{
status
}
"
%span
.has-tooltip
(
title=
"#{tooltip}"
)
{
class:
"ci-status-icon-#{status}"
}
=
ci_icon_for_status
(
status
)
...
...
spec/models/commit_status_spec.rb
View file @
8c93b605
...
...
@@ -185,5 +185,17 @@ describe CommitStatus, models: true do
is_expected
.
to
eq
(
%w(build test deploy)
)
end
end
context
'stages with statuses'
do
subject
{
CommitStatus
.
where
(
commit:
commit
).
stages_status
}
it
'return list of stages with statuses'
do
is_expected
.
to
eq
({
'build'
=>
'failed'
,
'test'
=>
'success'
,
'deploy'
=>
'running'
})
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