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
2ee8af3e
Commit
2ee8af3e
authored
Jun 12, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
73609873
99197664
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
33 additions
and
15 deletions
+33
-15
app/models/project.rb
app/models/project.rb
+1
-1
app/presenters/ci/build_runner_presenter.rb
app/presenters/ci/build_runner_presenter.rb
+1
-1
app/services/projects/fork_service.rb
app/services/projects/fork_service.rb
+3
-3
changelogs/unreleased/expose-project-git-depth-via-api.yml
changelogs/unreleased/expose-project-git-depth-via-api.yml
+5
-0
doc/api/projects.md
doc/api/projects.md
+7
-0
lib/api/entities.rb
lib/api/entities.rb
+2
-0
lib/api/helpers/projects_helpers.rb
lib/api/helpers/projects_helpers.rb
+1
-0
qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb
...igure/auto_devops/create_project_with_auto_devops_spec.rb
+2
-1
spec/controllers/projects/settings/ci_cd_controller_spec.rb
spec/controllers/projects/settings/ci_cd_controller_spec.rb
+1
-1
spec/presenters/ci/build_runner_presenter_spec.rb
spec/presenters/ci/build_runner_presenter_spec.rb
+1
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+2
-0
spec/requests/api/runner_spec.rb
spec/requests/api/runner_spec.rb
+3
-3
spec/services/projects/fork_service_spec.rb
spec/services/projects/fork_service_spec.rb
+4
-4
No files found.
app/models/project.rb
View file @
2ee8af3e
...
...
@@ -311,7 +311,7 @@ class Project < ApplicationRecord
delegate
:root_ancestor
,
to: :namespace
,
allow_nil:
true
delegate
:last_pipeline
,
to: :commit
,
allow_nil:
true
delegate
:external_dashboard_url
,
to: :metrics_setting
,
allow_nil:
true
,
prefix:
true
delegate
:default_git_depth
,
:default_git_depth
=
,
to: :ci_cd_settings
delegate
:default_git_depth
,
:default_git_depth
=
,
to: :ci_cd_settings
,
prefix: :ci
# Validations
validates
:creator
,
presence:
true
,
on: :create
...
...
app/presenters/ci/build_runner_presenter.rb
View file @
2ee8af3e
...
...
@@ -28,7 +28,7 @@ module Ci
if
git_depth_variable
git_depth_variable
[
:value
]
elsif
Feature
.
enabled?
(
:ci_project_git_depth
,
default_enabled:
true
)
project
.
default_git_depth
project
.
ci_
default_git_depth
end
.
to_i
end
...
...
app/services/projects/fork_service.rb
View file @
2ee8af3e
...
...
@@ -43,10 +43,10 @@ module Projects
shared_runners_enabled:
@project
.
shared_runners_enabled
,
namespace_id:
target_namespace
.
id
,
fork_network:
fork_network
,
# We need to set default_git_depth to 0 for the forked project when
# @project.default_git_depth is nil in order to keep the same behaviour
# We need to set
ci_
default_git_depth to 0 for the forked project when
# @project.
ci_
default_git_depth is nil in order to keep the same behaviour
# and not get ProjectCiCdSetting::DEFAULT_GIT_DEPTH set on create
ci_cd_settings_attributes:
{
default_git_depth:
@project
.
default_git_depth
||
0
},
ci_cd_settings_attributes:
{
default_git_depth:
@project
.
ci_
default_git_depth
||
0
},
# We need to assign the fork network membership after the project has
# been instantiated to avoid ActiveRecord trying to create it when
# initializing the project, as that would cause a foreign key constraint
...
...
changelogs/unreleased/expose-project-git-depth-via-api.yml
0 → 100644
View file @
2ee8af3e
---
title
:
Get and edit ci_default_git_depth via project API
merge_request
:
29353
author
:
type
:
added
doc/api/projects.md
View file @
2ee8af3e
...
...
@@ -143,6 +143,7 @@ When the user is authenticated and `simple` is not set this returns something li
"forks_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8547b1dc37721d05889db52fa2f02"
,
"ci_default_git_depth"
:
50
,
"public_jobs"
:
true
,
"shared_with_groups"
:
[],
"only_allow_merge_if_pipeline_succeeds"
:
false
,
...
...
@@ -227,6 +228,7 @@ When the user is authenticated and `simple` is not set this returns something li
"forks_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8547b1dc37721d05889db52fa2f02"
,
"ci_default_git_depth"
:
0
,
"public_jobs"
:
true
,
"shared_with_groups"
:
[],
"only_allow_merge_if_pipeline_succeeds"
:
false
,
...
...
@@ -338,6 +340,7 @@ GET /users/:user_id/projects
"forks_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8547b1dc37721d05889db52fa2f02"
,
"ci_default_git_depth"
:
50
,
"public_jobs"
:
true
,
"shared_with_groups"
:
[],
"only_allow_merge_if_pipeline_succeeds"
:
false
,
...
...
@@ -421,6 +424,7 @@ GET /users/:user_id/projects
"forks_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8547b1dc37721d05889db52fa2f02"
,
"ci_default_git_depth"
:
0
,
"public_jobs"
:
true
,
"shared_with_groups"
:
[],
"only_allow_merge_if_pipeline_succeeds"
:
false
,
...
...
@@ -534,6 +538,7 @@ GET /projects/:id
"forks_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8bc4a7a29eb76ea83cf79e4908c2b"
,
"ci_default_git_depth"
:
50
,
"public_jobs"
:
true
,
"shared_with_groups"
:
[
{
...
...
@@ -1199,6 +1204,7 @@ Example response:
"forks_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8bc4a7a29eb76ea83cf79e4908c2b"
,
"ci_default_git_depth"
:
50
,
"public_jobs"
:
true
,
"shared_with_groups"
:
[],
"only_allow_merge_if_pipeline_succeeds"
:
false
,
...
...
@@ -1303,6 +1309,7 @@ Example response:
"forks_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8bc4a7a29eb76ea83cf79e4908c2b"
,
"ci_default_git_depth"
:
50
,
"public_jobs"
:
true
,
"shared_with_groups"
:
[],
"only_allow_merge_if_pipeline_succeeds"
:
false
,
...
...
lib/api/entities.rb
View file @
2ee8af3e
...
...
@@ -265,6 +265,7 @@ module API
expose
:open_issues_count
,
if:
lambda
{
|
project
,
options
|
project
.
feature_available?
(
:issues
,
options
[
:current_user
])
}
expose
:runners_token
,
if:
lambda
{
|
_project
,
options
|
options
[
:user_can_admin_project
]
}
expose
:ci_default_git_depth
expose
:public_builds
,
as: :public_jobs
expose
:ci_config_path
,
if:
->
(
project
,
options
)
{
Ability
.
allowed?
(
options
[
:current_user
],
:download_code
,
project
)
}
expose
:shared_with_groups
do
|
project
,
options
|
...
...
@@ -287,6 +288,7 @@ module API
# N+1 is solved then by using `subject.tags.map(&:name)`
# MR describing the solution: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20555
super
(
projects_relation
).
preload
(
:group
)
.
preload
(
:ci_cd_settings
)
.
preload
(
project_group_links:
{
group: :route
},
fork_network: :root_project
,
fork_network_member: :forked_from_project
,
...
...
lib/api/helpers/projects_helpers.rb
View file @
2ee8af3e
...
...
@@ -29,6 +29,7 @@ module API
optional
:merge_method
,
type:
String
,
values:
%w(ff rebase_merge merge)
,
desc:
'The merge method used when merging merge requests'
optional
:initialize_with_readme
,
type:
Boolean
,
desc:
"Initialize a project with a README.md"
optional
:external_authorization_classification_label
,
type:
String
,
desc:
'The classification label for the project'
optional
:ci_default_git_depth
,
type:
Integer
,
desc:
'Default number of revisions for shallow cloning'
end
params
:optional_project_params_ee
do
...
...
qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb
View file @
2ee8af3e
...
...
@@ -9,7 +9,8 @@ module QA
Page
::
Main
::
Login
.
perform
(
&
:sign_in_using_credentials
)
end
describe
'Auto DevOps support'
,
:orchestrated
,
:kubernetes
do
# Failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/108
describe
'Auto DevOps support'
,
:orchestrated
,
:kubernetes
,
:quarantine
do
context
'when rbac is enabled'
do
before
(
:all
)
do
@cluster
=
Service
::
KubernetesCluster
.
new
.
create!
...
...
spec/controllers/projects/settings/ci_cd_controller_spec.rb
View file @
2ee8af3e
...
...
@@ -212,7 +212,7 @@ describe Projects::Settings::CiCdController do
subject
project
.
reload
expect
(
project
.
default_git_depth
).
to
eq
(
10
)
expect
(
project
.
ci_
default_git_depth
).
to
eq
(
10
)
end
end
end
...
...
spec/presenters/ci/build_runner_presenter_spec.rb
View file @
2ee8af3e
...
...
@@ -134,7 +134,7 @@ describe Ci::BuildRunnerPresenter do
end
it
'defaults to git depth setting for the project'
do
expect
(
git_depth
).
to
eq
(
build
.
project
.
default_git_depth
)
expect
(
git_depth
).
to
eq
(
build
.
project
.
ci_
default_git_depth
)
end
context
'when feature flag :ci_project_git_depth is disabled'
do
...
...
spec/requests/api/projects_spec.rb
View file @
2ee8af3e
...
...
@@ -1125,6 +1125,7 @@ describe API::Projects do
expect
(
json_response
[
'shared_with_groups'
][
0
][
'expires_at'
]).
to
be_nil
expect
(
json_response
[
'only_allow_merge_if_pipeline_succeeds'
]).
to
eq
(
project
.
only_allow_merge_if_pipeline_succeeds
)
expect
(
json_response
[
'only_allow_merge_if_all_discussions_are_resolved'
]).
to
eq
(
project
.
only_allow_merge_if_all_discussions_are_resolved
)
expect
(
json_response
[
'ci_default_git_depth'
]).
to
eq
(
project
.
ci_default_git_depth
)
expect
(
json_response
[
'merge_method'
]).
to
eq
(
project
.
merge_method
.
to_s
)
expect
(
json_response
[
'readme_url'
]).
to
eq
(
project
.
readme_url
)
end
...
...
@@ -1963,6 +1964,7 @@ describe API::Projects do
snippets_enabled:
true
,
merge_requests_enabled:
true
,
merge_method:
'ff'
,
ci_default_git_depth:
20
,
description:
'new description'
}
put
api
(
"/projects/
#{
project3
.
id
}
"
,
user4
),
params:
project_param
...
...
spec/requests/api/runner_spec.rb
View file @
2ee8af3e
...
...
@@ -445,7 +445,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
'before_sha'
=>
job
.
before_sha
,
'ref_type'
=>
'branch'
,
'refspecs'
=>
[
"+refs/heads/
#{
job
.
ref
}
:refs/remotes/origin/
#{
job
.
ref
}
"
],
'depth'
=>
project
.
default_git_depth
}
'depth'
=>
project
.
ci_
default_git_depth
}
end
let
(
:expected_steps
)
do
...
...
@@ -533,7 +533,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
context
'when GIT_DEPTH is not specified and there is no default git depth for the project'
do
before
do
project
.
update!
(
default_git_depth:
nil
)
project
.
update!
(
ci_
default_git_depth:
nil
)
end
it
'specifies refspecs'
do
...
...
@@ -593,7 +593,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
context
'when GIT_DEPTH is not specified and there is no default git depth for the project'
do
before
do
project
.
update!
(
default_git_depth:
nil
)
project
.
update!
(
ci_
default_git_depth:
nil
)
end
it
'specifies refspecs'
do
...
...
spec/services/projects/fork_service_spec.rb
View file @
2ee8af3e
...
...
@@ -150,21 +150,21 @@ describe Projects::ForkService do
context
"when origin has git depth specified"
do
before
do
@from_project
.
update
(
default_git_depth:
42
)
@from_project
.
update
(
ci_
default_git_depth:
42
)
end
it
"inherits default_git_depth from the origin project"
do
expect
(
to_project
.
default_git_depth
).
to
eq
(
42
)
expect
(
to_project
.
ci_
default_git_depth
).
to
eq
(
42
)
end
end
context
"when origin does not define git depth"
do
before
do
@from_project
.
update!
(
default_git_depth:
nil
)
@from_project
.
update!
(
ci_
default_git_depth:
nil
)
end
it
"the fork has git depth set to 0"
do
expect
(
to_project
.
default_git_depth
).
to
eq
(
0
)
expect
(
to_project
.
ci_
default_git_depth
).
to
eq
(
0
)
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