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
Boxiang Sun
gitlab-ce
Commits
85409a5a
Commit
85409a5a
authored
Jul 18, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use ci_commits.ref (Pipeline#ref) to find builds
parent
5c1f75e9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
24 deletions
+15
-24
app/models/project.rb
app/models/project.rb
+2
-9
spec/models/build_spec.rb
spec/models/build_spec.rb
+3
-2
spec/requests/api/builds_spec.rb
spec/requests/api/builds_spec.rb
+1
-1
spec/requests/projects/artifacts_controller_spec.rb
spec/requests/projects/artifacts_controller_spec.rb
+1
-1
spec/requests/shared/artifacts_context.rb
spec/requests/shared/artifacts_context.rb
+8
-11
No files found.
app/models/project.rb
View file @
85409a5a
...
...
@@ -434,15 +434,8 @@ class Project < ActiveRecord::Base
end
def
builds_for
(
ref
=
'HEAD'
)
commit_object
=
commit
(
ref
)
if
commit_object
.
nil?
Ci
::
Build
.
none
else
Ci
::
Build
.
joins
(
:pipeline
).
merge
(
Ci
::
Pipeline
.
where
(
sha:
commit_object
.
sha
,
project:
self
))
end
Ci
::
Build
.
joins
(
:pipeline
).
merge
(
Ci
::
Pipeline
.
where
(
ref:
ref
,
project:
self
))
end
def
merge_base_commit
(
first_commit_id
,
second_commit_id
)
...
...
spec/models/build_spec.rb
View file @
85409a5a
...
...
@@ -5,7 +5,8 @@ describe Ci::Build, models: true do
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
id
)
sha:
project
.
commit
.
id
,
ref:
'fix'
)
end
let
(
:build
)
{
create
(
:ci_build
,
pipeline:
pipeline
)
}
...
...
@@ -698,7 +699,7 @@ describe Ci::Build, models: true do
end
it
'returns builds from ref'
do
builds
=
project
.
latest_success_builds_for
(
'
HEAD
'
)
builds
=
project
.
latest_success_builds_for
(
'
fix
'
)
expect
(
builds
).
to
contain_exactly
(
build
)
end
...
...
spec/requests/api/builds_spec.rb
View file @
85409a5a
...
...
@@ -190,7 +190,7 @@ describe API::API, api: true do
describe
'GET /projects/:id/artifacts/:ref_name/download?job=name'
do
include_context
'artifacts from ref and build name'
def
path_from_ref
(
ref
=
pipeline
.
sha
,
job
=
build
.
name
)
def
path_from_ref
(
ref
=
pipeline
.
ref
,
job
=
build
.
name
)
api
(
"/projects/
#{
project
.
id
}
/builds/artifacts/
#{
ref
}
/download?job=
#{
job
}
"
,
user
)
end
...
...
spec/requests/projects/artifacts_controller_spec.rb
View file @
85409a5a
...
...
@@ -10,7 +10,7 @@ describe Projects::ArtifactsController do
end
def
path_from_ref
(
ref
=
pipeline
.
sha
,
job
=
build
.
name
,
path
=
'browse'
)
ref
=
pipeline
.
ref
,
job
=
build
.
name
,
path
=
'browse'
)
search_namespace_project_artifacts_path
(
project
.
namespace
,
project
,
...
...
spec/requests/shared/artifacts_context.rb
View file @
85409a5a
...
...
@@ -2,7 +2,10 @@ shared_context 'artifacts from ref and build name' do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
do
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
(
'fix'
).
sha
)
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
(
'fix'
).
sha
,
ref:
'fix'
)
end
let
(
:build
)
{
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
pipeline
)
}
...
...
@@ -30,17 +33,10 @@ shared_examples 'artifacts from ref with 404' do
end
shared_examples
'artifacts from ref successfully'
do
context
'with sha'
do
before
do
get
path_from_ref
end
it
(
'gives the file'
)
{
verify
}
end
context
'with regular branch'
do
before
do
pipeline
.
update
(
sha:
project
.
commit
(
'master'
).
sha
)
pipeline
.
update
(
ref:
'master'
,
sha:
project
.
commit
(
'master'
).
sha
)
end
before
do
...
...
@@ -52,7 +48,8 @@ shared_examples 'artifacts from ref successfully' do
context
'with branch name containing slash'
do
before
do
pipeline
.
update
(
sha:
project
.
commit
(
'improve/awesome'
).
sha
)
pipeline
.
update
(
ref:
'improve/awesome'
,
sha:
project
.
commit
(
'improve/awesome'
).
sha
)
end
before
do
...
...
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