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
85ceb8b7
Commit
85ceb8b7
authored
Jul 19, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename latest_success* to latest_successful:
Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5142#note_13164642
parent
0538e1e9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
19 additions
and
19 deletions
+19
-19
artifacts_controller.rb
app/controllers/projects/artifacts_controller.rb
+1
-1
build.rb
app/models/ci/build.rb
+1
-1
project.rb
app/models/project.rb
+4
-4
_branch.html.haml
app/views/projects/branches/_branch.html.haml
+2
-2
_download.html.haml
app/views/projects/buttons/_download.html.haml
+2
-2
_download_archive.html.haml
app/views/projects/repositories/_download_archive.html.haml
+2
-2
_download.html.haml
app/views/projects/tags/_download.html.haml
+2
-2
builds.rb
lib/api/builds.rb
+1
-1
build_spec.rb
spec/models/build_spec.rb
+4
-4
No files found.
app/controllers/projects/artifacts_controller.rb
View file @
85ceb8b7
...
@@ -60,7 +60,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
...
@@ -60,7 +60,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def
build_from_ref
def
build_from_ref
if
params
[
:ref_name
]
if
params
[
:ref_name
]
builds
=
project
.
latest_success_builds_for
(
params
[
:ref_name
])
builds
=
project
.
latest_success
ful
_builds_for
(
params
[
:ref_name
])
builds
.
find_by
(
name:
params
[
:job
])
builds
.
find_by
(
name:
params
[
:job
])
end
end
...
...
app/models/ci/build.rb
View file @
85ceb8b7
...
@@ -15,7 +15,7 @@ module Ci
...
@@ -15,7 +15,7 @@ module Ci
scope
:with_artifacts
,
->
()
{
where
.
not
(
artifacts_file:
nil
)
}
scope
:with_artifacts
,
->
()
{
where
.
not
(
artifacts_file:
nil
)
}
scope
:with_expired_artifacts
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
scope
:with_expired_artifacts
,
->
()
{
with_artifacts
.
where
(
'artifacts_expire_at < ?'
,
Time
.
now
)
}
scope
:last_month
,
->
()
{
where
(
'created_at > ?'
,
Date
.
today
-
1
.
month
)
}
scope
:last_month
,
->
()
{
where
(
'created_at > ?'
,
Date
.
today
-
1
.
month
)
}
scope
:latest_success_with_artifacts
,
->
()
do
scope
:latest_success
ful
_with_artifacts
,
->
()
do
with_artifacts
.
success
.
order
(
id: :desc
)
with_artifacts
.
success
.
order
(
id: :desc
)
end
end
...
...
app/models/project.rb
View file @
85ceb8b7
...
@@ -430,7 +430,7 @@ class Project < ActiveRecord::Base
...
@@ -430,7 +430,7 @@ class Project < ActiveRecord::Base
end
end
# ref can't be HEAD, can only be branch/tag name or SHA
# ref can't be HEAD, can only be branch/tag name or SHA
def
latest_success_pipeline_for
(
ref
=
'master'
)
def
latest_success
ful
_pipeline_for
(
ref
=
'master'
)
table
=
Ci
::
Pipeline
.
quoted_table_name
table
=
Ci
::
Pipeline
.
quoted_table_name
# TODO: Use `where(ref: ref).or(sha: ref)` in Rails 5
# TODO: Use `where(ref: ref).or(sha: ref)` in Rails 5
pipelines
.
where
(
"
#{
table
}
.ref = ? OR
#{
table
}
.sha = ?"
,
ref
,
ref
).
pipelines
.
where
(
"
#{
table
}
.ref = ? OR
#{
table
}
.sha = ?"
,
ref
,
ref
).
...
@@ -438,10 +438,10 @@ class Project < ActiveRecord::Base
...
@@ -438,10 +438,10 @@ class Project < ActiveRecord::Base
end
end
# ref can't be HEAD, can only be branch/tag name or SHA
# ref can't be HEAD, can only be branch/tag name or SHA
def
latest_success_builds_for
(
ref
=
'master'
)
def
latest_success
ful
_builds_for
(
ref
=
'master'
)
Ci
::
Build
.
joins
(
:pipeline
).
Ci
::
Build
.
joins
(
:pipeline
).
merge
(
latest_success_pipeline_for
(
ref
)).
merge
(
latest_success
ful
_pipeline_for
(
ref
)).
latest_success_with_artifacts
latest_success
ful
_with_artifacts
end
end
def
merge_base_commit
(
first_commit_id
,
second_commit_id
)
def
merge_base_commit
(
first_commit_id
,
second_commit_id
)
...
...
app/views/projects/branches/_branch.html.haml
View file @
85ceb8b7
...
@@ -27,9 +27,9 @@
...
@@ -27,9 +27,9 @@
=
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
=
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
Compare
-
pipeline
=
@project
.
latest_success_pipeline_for
(
branch
.
name
).
first
-
pipeline
=
@project
.
latest_success
ful
_pipeline_for
(
branch
.
name
).
first
-
if
pipeline
-
if
pipeline
-
artifacts
=
pipeline
.
builds
.
latest_success_with_artifacts
-
artifacts
=
pipeline
.
builds
.
latest_success
ful
_with_artifacts
-
if
artifacts
.
any?
-
if
artifacts
.
any?
.dropdown.inline.artifacts-btn
.dropdown.inline.artifacts-btn
%a
.btn.dropdown-toggle
{
'data-toggle'
=>
'dropdown'
}
%a
.btn.dropdown-toggle
{
'data-toggle'
=>
'dropdown'
}
...
...
app/views/projects/buttons/_download.html.haml
View file @
85ceb8b7
...
@@ -14,9 +14,9 @@
...
@@ -14,9 +14,9 @@
%li
%li
=
link_to
archive_namespace_project_repository_path
(
@project
.
namespace
,
@project
,
ref:
@ref
,
format:
'tar.gz'
),
rel:
'nofollow'
do
=
link_to
archive_namespace_project_repository_path
(
@project
.
namespace
,
@project
,
ref:
@ref
,
format:
'tar.gz'
),
rel:
'nofollow'
do
%span
Download tar.gz
%span
Download tar.gz
-
pipeline
=
@project
.
latest_success_pipeline_for
(
@ref
).
first
-
pipeline
=
@project
.
latest_success
ful
_pipeline_for
(
@ref
).
first
-
if
pipeline
-
if
pipeline
-
artifacts
=
pipeline
.
builds
.
latest_success_with_artifacts
-
artifacts
=
pipeline
.
builds
.
latest_success
ful
_with_artifacts
-
if
artifacts
.
any?
-
if
artifacts
.
any?
%li
.dropdown-header
Artifacts
%li
.dropdown-header
Artifacts
-
unless
pipeline
.
latest?
-
unless
pipeline
.
latest?
...
...
app/views/projects/repositories/_download_archive.html.haml
View file @
85ceb8b7
...
@@ -25,9 +25,9 @@
...
@@ -25,9 +25,9 @@
=
link_to
archive_namespace_project_repository_path
(
@project
.
namespace
,
@project
,
ref:
ref
,
format:
'tar'
),
rel:
'nofollow'
do
=
link_to
archive_namespace_project_repository_path
(
@project
.
namespace
,
@project
,
ref:
ref
,
format:
'tar'
),
rel:
'nofollow'
do
%i
.fa.fa-download
%i
.fa.fa-download
%span
Download tar
%span
Download tar
-
pipeline
=
@project
.
latest_success_pipeline_for
(
ref
).
first
-
pipeline
=
@project
.
latest_success
ful
_pipeline_for
(
ref
).
first
-
if
pipeline
-
if
pipeline
-
artifacts
=
pipeline
.
builds
.
latest_success_with_artifacts
-
artifacts
=
pipeline
.
builds
.
latest_success
ful
_with_artifacts
-
if
artifacts
.
any?
-
if
artifacts
.
any?
%li
.dropdown-header
Artifacts
%li
.dropdown-header
Artifacts
-
unless
pipeline
.
latest?
-
unless
pipeline
.
latest?
...
...
app/views/projects/tags/_download.html.haml
View file @
85ceb8b7
...
@@ -12,9 +12,9 @@
...
@@ -12,9 +12,9 @@
%li
%li
=
link_to
archive_namespace_project_repository_path
(
project
.
namespace
,
project
,
ref:
ref
,
format:
'tar.gz'
),
rel:
'nofollow'
do
=
link_to
archive_namespace_project_repository_path
(
project
.
namespace
,
project
,
ref:
ref
,
format:
'tar.gz'
),
rel:
'nofollow'
do
%span
Download tar.gz
%span
Download tar.gz
-
pipeline
=
project
.
latest_success_pipeline_for
(
ref
).
first
-
pipeline
=
project
.
latest_success
ful
_pipeline_for
(
ref
).
first
-
if
pipeline
-
if
pipeline
-
artifacts
=
pipeline
.
builds
.
latest_success_with_artifacts
-
artifacts
=
pipeline
.
builds
.
latest_success
ful
_with_artifacts
-
if
artifacts
.
any?
-
if
artifacts
.
any?
%li
.dropdown-header
Artifacts
%li
.dropdown-header
Artifacts
-
unless
pipeline
.
latest?
-
unless
pipeline
.
latest?
...
...
lib/api/builds.rb
View file @
85ceb8b7
...
@@ -83,7 +83,7 @@ module API
...
@@ -83,7 +83,7 @@ module API
# GET /projects/:id/artifacts/:ref_name/download?job=name
# GET /projects/:id/artifacts/:ref_name/download?job=name
get
':id/builds/artifacts/:ref_name/download'
,
get
':id/builds/artifacts/:ref_name/download'
,
requirements:
{
ref_name:
/.+/
}
do
requirements:
{
ref_name:
/.+/
}
do
builds
=
user_project
.
latest_success_builds_for
(
params
[
:ref_name
])
builds
=
user_project
.
latest_success
ful
_builds_for
(
params
[
:ref_name
])
latest_build
=
builds
.
find_by!
(
name:
params
[
:job
])
latest_build
=
builds
.
find_by!
(
name:
params
[
:job
])
present_artifact!
(
latest_build
.
artifacts_file
)
present_artifact!
(
latest_build
.
artifacts_file
)
...
...
spec/models/build_spec.rb
View file @
85ceb8b7
...
@@ -678,7 +678,7 @@ describe Ci::Build, models: true do
...
@@ -678,7 +678,7 @@ describe Ci::Build, models: true do
end
end
end
end
describe
'Project#latest_success_builds_for'
do
describe
'Project#latest_success
ful
_builds_for'
do
let
(
:build
)
do
let
(
:build
)
do
create
(
:ci_build
,
:artifacts
,
:success
,
pipeline:
pipeline
)
create
(
:ci_build
,
:artifacts
,
:success
,
pipeline:
pipeline
)
end
end
...
@@ -689,13 +689,13 @@ describe Ci::Build, models: true do
...
@@ -689,13 +689,13 @@ describe Ci::Build, models: true do
context
'with succeed pipeline'
do
context
'with succeed pipeline'
do
it
'returns builds from ref'
do
it
'returns builds from ref'
do
builds
=
project
.
latest_success_builds_for
(
'fix'
)
builds
=
project
.
latest_success
ful
_builds_for
(
'fix'
)
expect
(
builds
).
to
contain_exactly
(
build
)
expect
(
builds
).
to
contain_exactly
(
build
)
end
end
it
'returns empty relation if the build cannot be found'
do
it
'returns empty relation if the build cannot be found'
do
builds
=
project
.
latest_success_builds_for
(
'TAIL'
).
all
builds
=
project
.
latest_success
ful
_builds_for
(
'TAIL'
).
all
expect
(
builds
).
to
be_empty
expect
(
builds
).
to
be_empty
end
end
...
@@ -707,7 +707,7 @@ describe Ci::Build, models: true do
...
@@ -707,7 +707,7 @@ describe Ci::Build, models: true do
end
end
it
'returns empty relation'
do
it
'returns empty relation'
do
builds
=
project
.
latest_success_builds_for
(
'fix'
).
all
builds
=
project
.
latest_success
ful
_builds_for
(
'fix'
).
all
expect
(
builds
).
to
be_empty
expect
(
builds
).
to
be_empty
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