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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
22c7737b
Commit
22c7737b
authored
Jan 09, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
5088da18
802de6dc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
128 additions
and
84 deletions
+128
-84
app/assets/stylesheets/pages/diff.scss
app/assets/stylesheets/pages/diff.scss
+1
-1
app/controllers/projects/artifacts_controller.rb
app/controllers/projects/artifacts_controller.rb
+2
-7
app/controllers/projects/build_artifacts_controller.rb
app/controllers/projects/build_artifacts_controller.rb
+2
-7
app/models/project.rb
app/models/project.rb
+9
-9
changelogs/unreleased/remove-gap-between-mr-tabs-and-file-header.yml
...unreleased/remove-gap-between-mr-tabs-and-file-header.yml
+5
-0
lib/api/job_artifacts.rb
lib/api/job_artifacts.rb
+2
-5
spec/models/project_spec.rb
spec/models/project_spec.rb
+107
-55
No files found.
app/assets/stylesheets/pages/diff.scss
View file @
22c7737b
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
@media
(
min-width
:
map-get
(
$grid-breakpoints
,
md
))
{
@media
(
min-width
:
map-get
(
$grid-breakpoints
,
md
))
{
position
:
-
webkit-sticky
;
position
:
-
webkit-sticky
;
position
:
sticky
;
position
:
sticky
;
top
:
92
px
;
top
:
$header-height
+
51
px
;
margin-left
:
-1px
;
margin-left
:
-1px
;
border-left
:
1px
solid
$border-color
;
border-left
:
1px
solid
$border-color
;
z-index
:
102
;
z-index
:
102
;
...
...
app/controllers/projects/artifacts_controller.rb
View file @
22c7737b
...
@@ -85,20 +85,15 @@ class Projects::ArtifactsController < Projects::ApplicationController
...
@@ -85,20 +85,15 @@ class Projects::ArtifactsController < Projects::ApplicationController
end
end
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
build_from_id
def
build_from_id
project
.
builds
.
find_by
(
id:
params
[
:job_id
])
if
params
[
:job_id
]
project
.
get_build
(
params
[
:job_id
])
if
params
[
:job_id
]
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
build_from_ref
def
build_from_ref
return
unless
@ref_name
return
unless
@ref_name
builds
=
project
.
latest_successful_builds_for
(
@ref_name
)
project
.
latest_successful_build_for
(
params
[
:job
],
@ref_name
)
builds
.
find_by
(
name:
params
[
:job
])
end
end
# rubocop: enable CodeReuse/ActiveRecord
def
artifacts_file
def
artifacts_file
@artifacts_file
||=
build
&
.
artifacts_file_for_type
(
params
[
:file_type
]
||
:archive
)
@artifacts_file
||=
build
&
.
artifacts_file_for_type
(
params
[
:file_type
]
||
:archive
)
...
...
app/controllers/projects/build_artifacts_controller.rb
View file @
22c7737b
...
@@ -44,18 +44,13 @@ class Projects::BuildArtifactsController < Projects::ApplicationController
...
@@ -44,18 +44,13 @@ class Projects::BuildArtifactsController < Projects::ApplicationController
@job
||=
job_from_id
||
job_from_ref
@job
||=
job_from_id
||
job_from_ref
end
end
# rubocop: disable CodeReuse/ActiveRecord
def
job_from_id
def
job_from_id
project
.
builds
.
find_by
(
id:
params
[
:build_id
])
if
params
[
:build_id
]
project
.
get_build
(
params
[
:build_id
])
if
params
[
:build_id
]
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
job_from_ref
def
job_from_ref
return
unless
@ref_name
return
unless
@ref_name
jobs
=
project
.
latest_successful_builds_for
(
@ref_name
)
project
.
latest_successful_build_for
(
params
[
:job
],
@ref_name
)
jobs
.
find_by
(
name:
params
[
:job
])
end
end
# rubocop: enable CodeReuse/ActiveRecord
end
end
app/models/project.rb
View file @
22c7737b
...
@@ -647,19 +647,19 @@ class Project < ActiveRecord::Base
...
@@ -647,19 +647,19 @@ 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_successful_build
s_for
(
ref
=
default_branch
)
def
latest_successful_build
_for
(
job_name
,
ref
=
default_branch
)
latest_pipeline
=
ci_pipelines
.
latest_successful_for
(
ref
)
latest_pipeline
=
ci_pipelines
.
latest_successful_for
(
ref
)
return
unless
latest_pipeline
if
latest_pipeline
latest_pipeline
.
builds
.
latest
.
with_artifacts_archive
.
find_by
(
name:
job_name
)
latest_pipeline
.
builds
.
latest
.
with_artifacts_archive
else
builds
.
none
end
end
end
def
latest_successful_build_for
(
job_name
,
ref
=
default_branch
)
def
latest_successful_build_for!
(
job_name
,
ref
=
default_branch
)
builds
=
latest_successful_builds_for
(
ref
)
latest_successful_build_for
(
job_name
,
ref
)
||
raise
(
ActiveRecord
::
RecordNotFound
.
new
(
"Couldn't find job
#{
job_name
}
"
))
builds
.
find_by!
(
name:
job_name
)
end
def
get_build
(
id
)
builds
.
find_by
(
id:
id
)
end
end
def
merge_base_commit
(
first_commit_id
,
second_commit_id
)
def
merge_base_commit
(
first_commit_id
,
second_commit_id
)
...
...
changelogs/unreleased/remove-gap-between-mr-tabs-and-file-header.yml
0 → 100644
View file @
22c7737b
---
title
:
Remove extra space between MR tab bar and sticky file headers
merge_request
:
author
:
type
:
fixed
lib/api/job_artifacts.rb
View file @
22c7737b
...
@@ -25,17 +25,14 @@ module API
...
@@ -25,17 +25,14 @@ module API
requires
:job
,
type:
String
,
desc:
'The name for the job'
requires
:job
,
type:
String
,
desc:
'The name for the job'
end
end
route_setting
:authentication
,
job_token_allowed:
true
route_setting
:authentication
,
job_token_allowed:
true
# rubocop: disable CodeReuse/ActiveRecord
get
':id/jobs/artifacts/:ref_name/download'
,
get
':id/jobs/artifacts/:ref_name/download'
,
requirements:
{
ref_name:
/.+/
}
do
requirements:
{
ref_name:
/.+/
}
do
authorize_download_artifacts!
authorize_download_artifacts!
builds
=
user_project
.
latest_successful_builds_for
(
params
[
:ref_name
])
latest_build
=
user_project
.
latest_successful_build_for!
(
params
[
:job
],
params
[
:ref_name
])
latest_build
=
builds
.
find_by!
(
name:
params
[
:job
])
present_carrierwave_file!
(
latest_build
.
artifacts_file
)
present_carrierwave_file!
(
latest_build
.
artifacts_file
)
end
end
# rubocop: enable CodeReuse/ActiveRecord
desc
'Download a specific file from artifacts archive from a ref'
do
desc
'Download a specific file from artifacts archive from a ref'
do
detail
'This feature was introduced in GitLab 11.5'
detail
'This feature was introduced in GitLab 11.5'
...
@@ -50,7 +47,7 @@ module API
...
@@ -50,7 +47,7 @@ module API
requirements:
{
ref_name:
/.+/
}
do
requirements:
{
ref_name:
/.+/
}
do
authorize_download_artifacts!
authorize_download_artifacts!
build
=
user_project
.
latest_successful_build_for
(
params
[
:job
],
params
[
:ref_name
])
build
=
user_project
.
latest_successful_build_for
!
(
params
[
:job
],
params
[
:ref_name
])
path
=
Gitlab
::
Ci
::
Build
::
Artifacts
::
Path
path
=
Gitlab
::
Ci
::
Build
::
Artifacts
::
Path
.
new
(
params
[
:artifact_path
])
.
new
(
params
[
:artifact_path
])
...
...
spec/models/project_spec.rb
View file @
22c7737b
...
@@ -1233,13 +1233,13 @@ describe Project do
...
@@ -1233,13 +1233,13 @@ describe Project do
describe
'#pipeline_for'
do
describe
'#pipeline_for'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let!
(
:pipeline
)
{
create_pipeline
}
let!
(
:pipeline
)
{
create_pipeline
(
project
)
}
shared_examples
'giving the correct pipeline'
do
shared_examples
'giving the correct pipeline'
do
it
{
is_expected
.
to
eq
(
pipeline
)
}
it
{
is_expected
.
to
eq
(
pipeline
)
}
context
'return latest'
do
context
'return latest'
do
let!
(
:pipeline2
)
{
create_pipeline
}
let!
(
:pipeline2
)
{
create_pipeline
(
project
)
}
it
{
is_expected
.
to
eq
(
pipeline2
)
}
it
{
is_expected
.
to
eq
(
pipeline2
)
}
end
end
...
@@ -1256,13 +1256,6 @@ describe Project do
...
@@ -1256,13 +1256,6 @@ describe Project do
it_behaves_like
'giving the correct pipeline'
it_behaves_like
'giving the correct pipeline'
end
end
def
create_pipeline
create
(
:ci_pipeline
,
project:
project
,
ref:
'master'
,
sha:
project
.
commit
(
'master'
).
sha
)
end
end
end
describe
'#builds_enabled'
do
describe
'#builds_enabled'
do
...
@@ -2062,38 +2055,21 @@ describe Project do
...
@@ -2062,38 +2055,21 @@ describe Project do
end
end
end
end
describe
'#latest_successful_builds_for and #latest_successful_build_for'
do
describe
'#latest_successful_build_for'
do
def
create_pipeline
(
status
=
'success'
)
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
project
.
default_branch
,
status:
status
)
end
def
create_build
(
new_pipeline
=
pipeline
,
name
=
'test'
)
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
new_pipeline
,
status:
new_pipeline
.
status
,
name:
name
)
end
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:pipeline
)
{
create_pipeline
}
let
(
:pipeline
)
{
create_pipeline
(
project
)
}
context
'with many builds'
do
context
'with many builds'
do
it
'gives the latest builds from latest pipeline'
do
it
'gives the latest builds from latest pipeline'
do
pipeline1
=
create_pipeline
pipeline1
=
create_pipeline
(
project
)
pipeline2
=
create_pipeline
pipeline2
=
create_pipeline
(
project
)
create_build
(
pipeline1
,
'test'
)
create_build
(
pipeline1
,
'test'
)
create_build
(
pipeline1
,
'test2'
)
create_build
(
pipeline1
,
'test2'
)
build1_p2
=
create_build
(
pipeline2
,
'test'
)
build1_p2
=
create_build
(
pipeline2
,
'test'
)
build2_p2
=
create_build
(
pipeline2
,
'test2'
)
create_build
(
pipeline2
,
'test2'
)
latest_builds
=
project
.
latest_successful_builds_for
expect
(
project
.
latest_successful_build_for
(
build1_p2
.
name
))
single_build
=
project
.
latest_successful_build_for
(
build1_p2
.
name
)
.
to
eq
(
build1_p2
)
expect
(
latest_builds
).
to
contain_exactly
(
build2_p2
,
build1_p2
)
expect
(
single_build
).
to
eq
(
build1_p2
)
end
end
end
end
...
@@ -2102,53 +2078,115 @@ describe Project do
...
@@ -2102,53 +2078,115 @@ describe Project do
context
'standalone pipeline'
do
context
'standalone pipeline'
do
it
'returns builds for ref for default_branch'
do
it
'returns builds for ref for default_branch'
do
builds
=
project
.
latest_successful_builds_for
expect
(
project
.
latest_successful_build_for
(
build
.
name
))
single_build
=
project
.
latest_successful_build_for
(
build
.
name
)
.
to
eq
(
build
)
end
expect
(
builds
).
to
contain_exactly
(
build
)
it
'returns empty relation if the build cannot be found'
do
expect
(
single_build
).
to
eq
(
build
)
expect
(
project
.
latest_successful_build_for
(
'TAIL'
))
.
to
be_nil
end
end
end
it
'returns empty relation if the build cannot be found for #latest_successful_builds_for'
do
context
'with some pending pipeline'
do
builds
=
project
.
latest_successful_builds_for
(
'TAIL'
)
before
do
create_build
(
create_pipeline
(
project
,
'pending'
))
end
expect
(
builds
).
to
be_kind_of
(
ActiveRecord
::
Relation
)
it
'gives the latest build from latest pipeline'
do
expect
(
builds
).
to
be_empty
expect
(
project
.
latest_successful_build_for
(
build
.
name
))
.
to
eq
(
build
)
end
end
end
end
it
'returns exception if the build cannot be found for #latest_successful_build_for'
do
context
'with pending pipeline'
do
expect
{
project
.
latest_successful_build_for
(
build
.
name
,
'TAIL'
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
it
'returns empty relation'
do
pipeline
.
update
(
status:
'pending'
)
pending_build
=
create_build
(
pipeline
)
expect
(
project
.
latest_successful_build_for
(
pending_build
.
name
)).
to
be_nil
end
end
end
describe
'#latest_successful_build_for!'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:pipeline
)
{
create_pipeline
(
project
)
}
context
'with many builds'
do
it
'gives the latest builds from latest pipeline'
do
pipeline1
=
create_pipeline
(
project
)
pipeline2
=
create_pipeline
(
project
)
create_build
(
pipeline1
,
'test'
)
create_build
(
pipeline1
,
'test2'
)
build1_p2
=
create_build
(
pipeline2
,
'test'
)
create_build
(
pipeline2
,
'test2'
)
expect
(
project
.
latest_successful_build_for
(
build1_p2
.
name
))
.
to
eq
(
build1_p2
)
end
end
context
'with succeeded pipeline'
do
let!
(
:build
)
{
create_build
}
context
'standalone pipeline'
do
it
'returns builds for ref for default_branch'
do
expect
(
project
.
latest_successful_build_for!
(
build
.
name
))
.
to
eq
(
build
)
end
it
'returns exception if the build cannot be found'
do
expect
{
project
.
latest_successful_build_for!
(
build
.
name
,
'TAIL'
)
}
.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
end
end
context
'with some pending pipeline'
do
context
'with some pending pipeline'
do
before
do
before
do
create_build
(
create_pipeline
(
'pending'
))
create_build
(
create_pipeline
(
project
,
'pending'
))
end
end
it
'gives the latest build from latest pipeline'
do
it
'gives the latest build from latest pipeline'
do
latest_builds
=
project
.
latest_successful_builds_for
expect
(
project
.
latest_successful_build_for!
(
build
.
name
))
last_single_build
=
project
.
latest_successful_build_for
(
build
.
name
)
.
to
eq
(
build
)
expect
(
latest_builds
).
to
contain_exactly
(
build
)
expect
(
last_single_build
).
to
eq
(
build
)
end
end
end
end
end
end
context
'with pending pipeline'
do
context
'with pending pipeline'
do
before
do
it
'returns empty relation'
do
pipeline
.
update
(
status:
'pending'
)
pipeline
.
update
(
status:
'pending'
)
create_build
(
pipeline
)
pending_build
=
create_build
(
pipeline
)
expect
{
project
.
latest_successful_build_for!
(
pending_build
.
name
)
}
.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
end
end
it
'returns empty relation'
do
describe
'#get_build'
do
builds
=
project
.
latest_successful_builds_for
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:ci_pipeline
)
{
create
(
:ci_pipeline
,
project:
project
)
}
context
'when build exists'
do
context
'build is associated with project'
do
let
(
:build
)
{
create
(
:ci_build
,
:success
,
pipeline:
ci_pipeline
)
}
it
{
expect
(
project
.
get_build
(
build
.
id
)).
to
eq
(
build
)
}
end
expect
(
builds
).
to
be_kind_of
(
ActiveRecord
::
Relation
)
context
'build is not associated with project'
do
expect
(
builds
).
to
be_empty
let
(
:build
)
{
create
(
:ci_build
,
:success
)
}
it
{
expect
(
project
.
get_build
(
build
.
id
)).
to
be_nil
}
end
end
end
end
context
'build does not exists'
do
it
{
expect
(
project
.
get_build
(
rand
100
)).
to
be_nil
}
end
end
end
describe
'#import_status'
do
describe
'#import_status'
do
...
@@ -4671,4 +4709,18 @@ describe Project do
...
@@ -4671,4 +4709,18 @@ describe Project do
def
rugged_config
def
rugged_config
rugged_repo
(
project
.
repository
).
config
rugged_repo
(
project
.
repository
).
config
end
end
def
create_pipeline
(
project
,
status
=
'success'
)
create
(
:ci_pipeline
,
project:
project
,
sha:
project
.
commit
.
sha
,
ref:
project
.
default_branch
,
status:
status
)
end
def
create_build
(
new_pipeline
=
pipeline
,
name
=
'test'
)
create
(
:ci_build
,
:success
,
:artifacts
,
pipeline:
new_pipeline
,
status:
new_pipeline
.
status
,
name:
name
)
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