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
Jérome Perrin
gitlab-ce
Commits
3483ae91
Commit
3483ae91
authored
Dec 27, 2016
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch 'fix-latest-pipeine-ordering' into 'master'
This reverts commit
bdcdf454
.
parent
ffca0da0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+5
-2
app/models/project.rb
app/models/project.rb
+1
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+8
-6
No files found.
app/models/ci/pipeline.rb
View file @
3483ae91
...
@@ -93,8 +93,11 @@ module Ci
...
@@ -93,8 +93,11 @@ module Ci
.
select
(
"max(
#{
quoted_table_name
}
.id)"
)
.
select
(
"max(
#{
quoted_table_name
}
.id)"
)
.
group
(
:ref
,
:sha
)
.
group
(
:ref
,
:sha
)
relation
=
ref
?
where
(
ref:
ref
)
:
self
if
ref
relation
.
where
(
id:
max_id
).
order
(
id: :desc
)
where
(
id:
max_id
,
ref:
ref
)
else
where
(
id:
max_id
)
end
end
end
def
self
.
latest_status
(
ref
=
nil
)
def
self
.
latest_status
(
ref
=
nil
)
...
...
app/models/project.rb
View file @
3483ae91
...
@@ -418,7 +418,7 @@ class Project < ActiveRecord::Base
...
@@ -418,7 +418,7 @@ class Project < ActiveRecord::Base
repository
.
commit
(
ref
)
repository
.
commit
(
ref
)
end
end
# ref can't be HEAD
or SHA, can only be branch/tag name
# ref can't be HEAD
, can only be branch/tag name or SHA
def
latest_successful_builds_for
(
ref
=
default_branch
)
def
latest_successful_builds_for
(
ref
=
default_branch
)
latest_pipeline
=
pipelines
.
latest_successful_for
(
ref
)
latest_pipeline
=
pipelines
.
latest_successful_for
(
ref
)
...
...
spec/models/ci/pipeline_spec.rb
View file @
3483ae91
...
@@ -424,18 +424,20 @@ describe Ci::Pipeline, models: true do
...
@@ -424,18 +424,20 @@ describe Ci::Pipeline, models: true do
context
'when no ref is specified'
do
context
'when no ref is specified'
do
let
(
:pipelines
)
{
described_class
.
latest
.
all
}
let
(
:pipelines
)
{
described_class
.
latest
.
all
}
it
'gives the latest pipelines for the same ref and different sha in reverse chronological order'
do
it
'returns the latest pipeline for the same ref and different sha'
do
expect
(
pipelines
.
map
(
&
:sha
)).
to
eq
(
%w[C B A]
)
expect
(
pipelines
.
map
(
&
:sha
)).
to
contain_exactly
(
'A'
,
'B'
,
'C'
)
expect
(
pipelines
.
map
(
&
:status
)).
to
eq
(
%w[skipped failed success]
)
expect
(
pipelines
.
map
(
&
:status
)).
to
contain_exactly
(
'success'
,
'failed'
,
'skipped'
)
end
end
end
end
context
'when ref is specified'
do
context
'when ref is specified'
do
let
(
:pipelines
)
{
described_class
.
latest
(
'ref'
).
all
}
let
(
:pipelines
)
{
described_class
.
latest
(
'ref'
).
all
}
it
'gives the latest pipelines for ref and different sha in reverse chronological order'
do
it
'returns the latest pipeline for ref and different sha'
do
expect
(
pipelines
.
map
(
&
:sha
)).
to
eq
(
%w[B A]
)
expect
(
pipelines
.
map
(
&
:sha
)).
to
contain_exactly
(
'A'
,
'B'
)
expect
(
pipelines
.
map
(
&
:status
)).
to
eq
(
%w[failed success]
)
expect
(
pipelines
.
map
(
&
:status
)).
to
contain_exactly
(
'success'
,
'failed'
)
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