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
5c0f2541
Commit
5c0f2541
authored
Dec 23, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-latest-pipeine-ordering' into 'master'
Fix code that selects latest pipelines Closes #25993 and #26031 See merge request !8286
parents
0b95f765
332b85d2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
14 deletions
+13
-14
pipeline.rb
app/models/ci/pipeline.rb
+2
-5
project.rb
app/models/project.rb
+1
-1
fix-latest-pipeine-ordering.yml
changelogs/unreleased/fix-latest-pipeine-ordering.yml
+4
-0
pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+6
-8
No files found.
app/models/ci/pipeline.rb
View file @
5c0f2541
...
@@ -93,11 +93,8 @@ module Ci
...
@@ -93,11 +93,8 @@ module Ci
.
select
(
"max(
#{
quoted_table_name
}
.id)"
)
.
select
(
"max(
#{
quoted_table_name
}
.id)"
)
.
group
(
:ref
,
:sha
)
.
group
(
:ref
,
:sha
)
if
ref
relation
=
ref
?
where
(
ref:
ref
)
:
self
where
(
id:
max_id
,
ref:
ref
)
relation
.
where
(
id:
max_id
).
order
(
id: :desc
)
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 @
5c0f2541
...
@@ -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
, can only be branch/tag name or SHA
# ref can't be HEAD
or SHA, can only be branch/tag name
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
)
...
...
changelogs/unreleased/fix-latest-pipeine-ordering.yml
0 → 100644
View file @
5c0f2541
---
title
:
Fix finding the latest pipeline
merge_request
:
8286
author
:
spec/models/ci/pipeline_spec.rb
View file @
5c0f2541
...
@@ -424,20 +424,18 @@ describe Ci::Pipeline, models: true do
...
@@ -424,20 +424,18 @@ 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
'returns the latest pipeline for the same ref and different sha'
do
it
'gives the latest pipelines for the same ref and different sha in reverse chronological order'
do
expect
(
pipelines
.
map
(
&
:sha
)).
to
contain_exactly
(
'A'
,
'B'
,
'C'
)
expect
(
pipelines
.
map
(
&
:sha
)).
to
eq
(
%w[C B A]
)
expect
(
pipelines
.
map
(
&
:status
)).
expect
(
pipelines
.
map
(
&
:status
)).
to
eq
(
%w[skipped failed success]
)
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
'returns the latest pipeline for ref and different sha'
do
it
'gives the latest pipelines for ref and different sha in reverse chronological order'
do
expect
(
pipelines
.
map
(
&
:sha
)).
to
contain_exactly
(
'A'
,
'B'
)
expect
(
pipelines
.
map
(
&
:sha
)).
to
eq
(
%w[B A]
)
expect
(
pipelines
.
map
(
&
:status
)).
expect
(
pipelines
.
map
(
&
:status
)).
to
eq
(
%w[failed success]
)
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