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
796b5b57
Commit
796b5b57
authored
Dec 26, 2016
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix-latest-pipeine-ordering-again' into 'master'
Order only for latest_successful_for See merge request !8301
parents
f8bab610
e60bf0d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
6 deletions
+20
-6
pipeline.rb
app/models/ci/pipeline.rb
+3
-6
fix-latest-pipeine-ordering.yml
changelogs/unreleased/fix-latest-pipeine-ordering.yml
+4
-0
pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+13
-0
No files found.
app/models/ci/pipeline.rb
View file @
796b5b57
...
...
@@ -93,11 +93,8 @@ module Ci
.
select
(
"max(
#{
quoted_table_name
}
.id)"
)
.
group
(
:ref
,
:sha
)
if
ref
where
(
id:
max_id
,
ref:
ref
)
else
where
(
id:
max_id
)
end
relation
=
ref
?
where
(
ref:
ref
)
:
self
relation
.
where
(
id:
max_id
)
end
def
self
.
latest_status
(
ref
=
nil
)
...
...
@@ -105,7 +102,7 @@ module Ci
end
def
self
.
latest_successful_for
(
ref
)
success
.
latest
(
ref
).
first
success
.
latest
(
ref
).
order
(
id: :desc
).
first
end
def
self
.
truncate_sha
(
sha
)
...
...
changelogs/unreleased/fix-latest-pipeine-ordering.yml
0 → 100644
View file @
796b5b57
---
title
:
Fix finding the latest pipeline
merge_request
:
8301
author
:
spec/models/ci/pipeline_spec.rb
View file @
796b5b57
...
...
@@ -464,6 +464,19 @@ describe Ci::Pipeline, models: true do
end
end
describe
'.latest_successful_for'
do
include_context
'with some outdated pipelines'
let!
(
:latest_successful_pipeline
)
do
create_pipeline
(
:success
,
'ref'
,
'D'
)
end
it
'returns the latest successful pipeline'
do
expect
(
described_class
.
latest_successful_for
(
'ref'
)).
to
eq
(
latest_successful_pipeline
)
end
end
describe
'#status'
do
let!
(
:build
)
{
create
(
:ci_build
,
:created
,
pipeline:
pipeline
,
name:
'test'
)
}
...
...
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