Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
f1abf4842160
Commit
f1abf484
authored
Aug 11, 2016
by
Lin Jen-Shin
Browse files
Make Pipeline.latest_successful_for return the record
parent
87149b105ded
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/models/ci/pipeline.rb
View file @
f1abf484
...
...
@@ -21,12 +21,8 @@
after_save
:keep_around_commits
# ref can't be HEAD or SHA, can only be branch/tag name
scope
:latest_successful_for
,
->
(
ref
)
do
latest_for
(
ref
).
success
end
scope
:latest_for
,
->
(
ref
)
do
where
(
ref:
ref
).
order
(
id: :desc
).
limit
(
1
)
def
self
.
latest_successful_for
(
ref
)
where
(
ref:
ref
).
order
(
id: :desc
).
success
.
first
end
def
self
.
truncate_sha
(
sha
)
...
...
app/models/project.rb
View file @
f1abf484
...
...
@@ -432,7 +432,7 @@
# ref can't be HEAD, can only be branch/tag name or SHA
def
latest_successful_builds_for
(
ref
=
default_branch
)
latest_pipeline
=
pipelines
.
latest_successful_for
(
ref
)
.
first
latest_pipeline
=
pipelines
.
latest_successful_for
(
ref
)
if
latest_pipeline
latest_pipeline
.
builds
.
latest
.
with_artifacts
...
...
app/views/projects/branches/_branch.html.haml
View file @
f1abf484
...
...
@@ -27,7 +27,7 @@
=
link_to
namespace_project_compare_index_path
(
@project
.
namespace
,
@project
,
from:
@repository
.
root_ref
,
to:
branch
.
name
),
class:
'btn btn-default'
,
method: :post
,
title:
"Compare"
do
Compare
-
pipeline
=
@project
.
pipelines
.
latest_successful_for
(
branch
.
name
)
.
first
-
pipeline
=
@project
.
pipelines
.
latest_successful_for
(
branch
.
name
)
-
if
pipeline
-
artifacts
=
pipeline
.
builds
.
latest
.
with_artifacts
-
if
artifacts
.
any?
...
...
app/views/projects/buttons/_download.html.haml
View file @
f1abf484
...
...
@@ -14,7 +14,7 @@
%li
=
link_to
archive_namespace_project_repository_path
(
@project
.
namespace
,
@project
,
ref:
@ref
,
format:
'tar.gz'
),
rel:
'nofollow'
do
%span
Download tar.gz
-
pipeline
=
@project
.
pipelines
.
latest_successful_for
(
@ref
)
.
first
-
pipeline
=
@project
.
pipelines
.
latest_successful_for
(
@ref
)
-
if
pipeline
-
artifacts
=
pipeline
.
builds
.
latest
.
with_artifacts
-
if
artifacts
.
any?
...
...
app/views/projects/repositories/_download_archive.html.haml
View file @
f1abf484
...
...
@@ -25,7 +25,7 @@
=
link_to
archive_namespace_project_repository_path
(
@project
.
namespace
,
@project
,
ref:
ref
,
format:
'tar'
),
rel:
'nofollow'
do
%i
.fa.fa-download
%span
Download tar
-
pipeline
=
@project
.
pipelines
.
latest_successful_for
(
ref
)
.
first
-
pipeline
=
@project
.
pipelines
.
latest_successful_for
(
ref
)
-
if
pipeline
-
artifacts
=
pipeline
.
builds
.
latest
.
with_artifacts
-
if
artifacts
.
any?
...
...
app/views/projects/tags/_download.html.haml
View file @
f1abf484
...
...
@@ -12,7 +12,7 @@
%li
=
link_to
archive_namespace_project_repository_path
(
project
.
namespace
,
project
,
ref:
ref
,
format:
'tar.gz'
),
rel:
'nofollow'
do
%span
Download tar.gz
-
pipeline
=
project
.
pipelines
.
latest_successful_for
(
ref
)
.
first
-
pipeline
=
project
.
pipelines
.
latest_successful_for
(
ref
)
-
if
pipeline
-
artifacts
=
pipeline
.
builds
.
latest
.
with_artifacts
-
if
artifacts
.
any?
...
...
Write
Preview
Supports
Markdown
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