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
18a71c47
Commit
18a71c47
authored
Nov 07, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show commit status from latest pipeline
Rather than compound status from all pipelines. Closes #20560
parent
7ce03197
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
24 deletions
+29
-24
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+5
-1
app/models/commit.rb
app/models/commit.rb
+9
-7
changelogs/unreleased/show-commit-status-from-latest-pipeline.yml
...gs/unreleased/show-commit-status-from-latest-pipeline.yml
+4
-0
spec/models/commit_spec.rb
spec/models/commit_spec.rb
+11
-16
No files found.
app/models/ci/pipeline.rb
View file @
18a71c47
...
@@ -83,9 +83,13 @@ module Ci
...
@@ -83,9 +83,13 @@ module Ci
end
end
end
end
scope
:latest
,
->
{
order
(
id: :desc
)
}
# ref can't be HEAD or SHA, can only be branch/tag name
# ref can't be HEAD or SHA, can only be branch/tag name
scope
:latest_for
,
->
(
ref
)
{
where
(
ref:
ref
).
latest
}
def
self
.
latest_successful_for
(
ref
)
def
self
.
latest_successful_for
(
ref
)
where
(
ref:
ref
).
order
(
id: :desc
).
success
.
first
latest_for
(
ref
).
success
.
first
end
end
def
self
.
truncate_sha
(
sha
)
def
self
.
truncate_sha
(
sha
)
...
...
app/models/commit.rb
View file @
18a71c47
...
@@ -232,13 +232,15 @@ class Commit
...
@@ -232,13 +232,15 @@ class Commit
def
status
(
ref
=
nil
)
def
status
(
ref
=
nil
)
@statuses
||=
{}
@statuses
||=
{}
if
@statuses
.
key?
(
ref
)
return
@statuses
[
ref
]
if
@statuses
.
key?
(
ref
)
@statuses
[
ref
]
els
if
ref
latest_pipeline
=
if
ref
@statuses
[
ref
]
=
pipelines
.
where
(
ref:
ref
).
status
pipelines
.
latest_for
(
ref
)
else
else
@statuses
[
ref
]
=
pipelines
.
status
pipelines
.
latest
end
end
.
first
@statuses
[
ref
]
=
latest_pipeline
.
try
(
:status
)
end
end
def
revert_branch_name
def
revert_branch_name
...
...
changelogs/unreleased/show-commit-status-from-latest-pipeline.yml
0 → 100644
View file @
18a71c47
---
title
:
Show commit status from latest pipeline
merge_request
:
7333
author
:
spec/models/commit_spec.rb
View file @
18a71c47
...
@@ -206,23 +206,18 @@ eos
...
@@ -206,23 +206,18 @@ eos
end
end
describe
'#status'
do
describe
'#status'
do
context
'without arguments for compound status'
do
context
'without arguments'
do
shared_examples
'giving the status from pipeline'
do
before
do
it
do
5
.
times
do
expect
(
commit
.
status
).
to
eq
(
Ci
::
Pipeline
.
status
)
create
(
:ci_empty_pipeline
,
end
project:
project
,
end
sha:
commit
.
sha
,
status:
Ci
::
Pipeline
.
all_state_names
.
sample
)
context
'with pipelines'
do
let!
(
:pipeline
)
do
create
(
:ci_empty_pipeline
,
project:
project
,
sha:
commit
.
sha
)
end
end
it_behaves_like
'giving the status from pipeline'
end
end
context
'without pipelines
'
do
it
'gives the status from latest pipeline
'
do
it_behaves_like
'giving the status from pipeline'
expect
(
commit
.
status
).
to
eq
(
Ci
::
Pipeline
.
latest
.
first
.
status
)
end
end
end
end
...
@@ -248,8 +243,8 @@ eos
...
@@ -248,8 +243,8 @@ eos
expect
(
commit
.
status
(
'fix'
)).
to
eq
(
pipeline_from_fix
.
status
)
expect
(
commit
.
status
(
'fix'
)).
to
eq
(
pipeline_from_fix
.
status
)
end
end
it
'gives
compound status if ref is nil
'
do
it
'gives
status from latest pipeline for whatever branch
'
do
expect
(
commit
.
status
(
nil
)).
to
eq
(
commi
t
.
status
)
expect
(
commit
.
status
(
nil
)).
to
eq
(
Ci
::
Pipeline
.
latest
.
firs
t
.
status
)
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