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
071482c65bfe
Commit
071482c6
authored
May 15, 2019
by
Mathieu Parent
Browse files
Add build_git_strategy attribute to project API
We map the boolean to the string 'fetch' or 'clone', to be more explicit.
parent
7a364010b126
Changes
7
Hide whitespace changes
Inline
Side-by-side
app/models/concerns/project_api_compatibility.rb
0 → 100644
View file @
071482c6
# frozen_string_literal: true
# Add methods used by the projects API
module
ProjectAPICompatibility
extend
ActiveSupport
::
Concern
def
build_git_strategy
=
(
value
)
write_attribute
(
:build_allow_git_fetch
,
value
==
'fetch'
)
end
end
app/models/project.rb
View file @
071482c6
...
...
@@ -15,6 +15,7 @@
include
CaseSensitivity
include
TokenAuthenticatable
include
ValidAttribute
include
ProjectAPICompatibility
include
ProjectFeaturesCompatibility
include
SelectForProjectAuthorization
include
Presentable
...
...
doc/api/projects.md
View file @
071482c6
...
...
@@ -733,6 +733,7 @@
|
`tag_list`
| array | no | The list of tags for a project; put array of tags, that should be finally assigned to a project |
|
`avatar`
| mixed | no | Image file for avatar of the project |
|
`printing_merge_request_link_enabled`
| boolean | no | Show link to create/view merge request when pushing from the command line |
|
`build_git_strategy`
| string | no | The Git strategy. Defaults to
`fetch`
|
|
`ci_config_path`
| string | no | The path to CI config file |
|
`repository_storage`
| string | no | Which storage shard the repository is on. Available only to admins |
|
`approvals_before_merge`
| integer | no |
**[STARTER]**
How many approvers should approve merge requests by default |
...
...
@@ -784,6 +785,7 @@
|
`tag_list`
| array | no | The list of tags for a project; put array of tags, that should be finally assigned to a project |
|
`avatar`
| mixed | no | Image file for avatar of the project |
|
`printing_merge_request_link_enabled`
| boolean | no | Show link to create/view merge request when pushing from the command line |
|
`build_git_strategy`
| string | no | The Git strategy. Defaults to
`fetch`
|
|
`ci_config_path`
| string | no | The path to CI config file |
|
`repository_storage`
| string | no | Which storage shard the repository is on. Available only to admins |
|
`approvals_before_merge`
| integer | no |
**[STARTER]**
How many approvers should approve merge requests by default |
...
...
@@ -834,6 +836,7 @@
|
`request_access_enabled`
| boolean | no | Allow users to request member access |
|
`tag_list`
| array | no | The list of tags for a project; put array of tags, that should be finally assigned to a project |
|
`avatar`
| mixed | no | Image file for avatar of the project |
|
`build_git_strategy`
| string | no | The Git strategy. Defaults to
`fetch`
|
|
`ci_config_path`
| string | no | The path to CI config file |
|
`ci_default_git_depth`
| integer | no | Default number of revisions for
[
shallow cloning
](
../user/project/pipelines/settings.md#git-shallow-clone
)
|
|
`repository_storage`
| string | no | Which storage shard the repository is on. Available only to admins |
...
...
lib/api/entities.rb
View file @
071482c6
...
...
@@ -275,6 +275,9 @@
expose
:runners_token
,
if:
lambda
{
|
_project
,
options
|
options
[
:user_can_admin_project
]
}
expose
:ci_default_git_depth
expose
:public_builds
,
as: :public_jobs
expose
:build_git_strategy
,
if:
lambda
{
|
project
,
options
|
options
[
:user_can_admin_project
]
}
do
|
project
,
options
|
project
.
build_allow_git_fetch
?
'fetch'
:
'clone'
end
expose
:ci_config_path
,
if:
->
(
project
,
options
)
{
Ability
.
allowed?
(
options
[
:current_user
],
:download_code
,
project
)
}
expose
:shared_with_groups
do
|
project
,
options
|
SharedGroup
.
represent
(
project
.
project_group_links
,
options
)
...
...
lib/api/helpers/projects_helpers.rb
View file @
071482c6
...
...
@@ -8,6 +8,7 @@
params
:optional_project_params_ce
do
optional
:description
,
type:
String
,
desc:
'The description of the project'
optional
:build_git_strategy
,
type:
String
,
values:
%w(fetch clone)
,
desc:
'The Git strategy. Defaults to `fetch`'
optional
:ci_config_path
,
type:
String
,
desc:
'The path to CI config file. Defaults to `.gitlab-ci.yml`'
# TODO: remove in API v5, replaced by *_access_level
...
...
@@ -58,6 +59,7 @@
def
self
.
update_params_at_least_one_of
[
:build_git_strategy
,
:builds_access_level
,
:ci_config_path
,
:container_registry_enabled
,
...
...
spec/models/concerns/project_api_compatibility_spec.rb
0 → 100644
View file @
071482c6
# frozen_string_literal: true
require
'spec_helper'
describe
ProjectAPICompatibility
do
let
(
:project
)
{
create
(
:project
)
}
it
"converts build_git_strategy=fetch to build_allow_git_fetch=true"
do
project
.
update!
(
:build_git_strategy
,
'fetch'
)
expect
(
project
.
build_allow_git_fetch
).
to
eq
(
true
)
end
it
"converts build_git_strategy=clone to build_allow_git_fetch=false"
do
project
.
update!
(
:build_git_strategy
,
'clone'
)
expect
(
project
.
build_allow_git_fetch
).
to
eq
(
false
)
end
end
spec/requests/api/projects_spec.rb
View file @
071482c6
...
...
@@ -1929,6 +1929,24 @@
expect
(
json_response
[
'builds_access_level'
]).
to
eq
(
'private'
)
end
it
'updates build_git_strategy'
do
project_param
=
{
build_git_strategy:
'clone'
}
put
api
(
"/projects/
#{
project3
.
id
}
"
,
user
),
params:
project_param
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'build_git_strategy'
]).
to
eq
(
'clone'
)
end
it
'rejects to update build_git_strategy when build_git_strategy is invalid'
do
project_param
=
{
build_git_strategy:
'invalid'
}
put
api
(
"/projects/
#{
project3
.
id
}
"
,
user
),
params:
project_param
expect
(
response
).
to
have_gitlab_http_status
(
400
)
end
it
'updates merge_method'
do
project_param
=
{
merge_method:
'ff'
}
...
...
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