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
Jérome Perrin
gitlab-ce
Commits
31b2c1ef
Commit
31b2c1ef
authored
Aug 22, 2016
by
Marc Dequènes (Duck)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
expose 'only_allow_merge_if_build_succeeds' project setting in the API
parent
02591b04
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
12 deletions
+53
-12
CHANGELOG
CHANGELOG
+1
-0
doc/api/projects.md
doc/api/projects.md
+17
-7
lib/api/entities.rb
lib/api/entities.rb
+1
-0
lib/api/projects.rb
lib/api/projects.rb
+6
-3
spec/javascripts/fixtures/projects.json
spec/javascripts/fixtures/projects.json
+1
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+27
-1
No files found.
CHANGELOG
View file @
31b2c1ef
...
@@ -4,6 +4,7 @@ v 8.12.0 (unreleased)
...
@@ -4,6 +4,7 @@ v 8.12.0 (unreleased)
- Change merge_error column from string to text type
- Change merge_error column from string to text type
- Optimistic locking for Issues and Merge Requests (title and description overriding prevention)
- Optimistic locking for Issues and Merge Requests (title and description overriding prevention)
- Added tests for diff notes
- Added tests for diff notes
- Added 'only_allow_merge_if_build_succeeds' project setting in the API. !5930 (Duck)
v 8.11.1 (unreleased)
v 8.11.1 (unreleased)
- Fix file links on project page when default view is Files !5933
- Fix file links on project page when default view is Files !5933
...
...
doc/api/projects.md
View file @
31b2c1ef
...
@@ -84,7 +84,8 @@ Parameters:
...
@@ -84,7 +84,8 @@ Parameters:
"star_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8547b1dc37721d05889db52fa2f02"
,
"runners_token"
:
"b8547b1dc37721d05889db52fa2f02"
,
"public_builds"
:
true
,
"public_builds"
:
true
,
"shared_with_groups"
:
[]
"shared_with_groups"
:
[],
"only_allow_merge_if_build_succeeds"
:
false
},
},
{
{
"id"
:
6
,
"id"
:
6
,
...
@@ -144,7 +145,8 @@ Parameters:
...
@@ -144,7 +145,8 @@ Parameters:
"star_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8547b1dc37721d05889db52fa2f02"
,
"runners_token"
:
"b8547b1dc37721d05889db52fa2f02"
,
"public_builds"
:
true
,
"public_builds"
:
true
,
"shared_with_groups"
:
[]
"shared_with_groups"
:
[],
"only_allow_merge_if_build_succeeds"
:
false
}
}
]
]
```
```
...
@@ -280,7 +282,8 @@ Parameters:
...
@@ -280,7 +282,8 @@ Parameters:
"group_name"
:
"Gitlab Org"
,
"group_name"
:
"Gitlab Org"
,
"group_access_level"
:
10
"group_access_level"
:
10
}
}
]
],
"only_allow_merge_if_build_succeeds"
:
false
}
}
```
```
...
@@ -448,6 +451,7 @@ Parameters:
...
@@ -448,6 +451,7 @@ Parameters:
-
`visibility_level`
(optional)
-
`visibility_level`
(optional)
-
`import_url`
(optional)
-
`import_url`
(optional)
-
`public_builds`
(optional)
-
`public_builds`
(optional)
-
`only_allow_merge_if_build_succeeds`
(optional)
### Create project for user
### Create project for user
...
@@ -473,6 +477,7 @@ Parameters:
...
@@ -473,6 +477,7 @@ Parameters:
-
`visibility_level`
(optional)
-
`visibility_level`
(optional)
-
`import_url`
(optional)
-
`import_url`
(optional)
-
`public_builds`
(optional)
-
`public_builds`
(optional)
-
`only_allow_merge_if_build_succeeds`
(optional)
### Edit project
### Edit project
...
@@ -499,6 +504,7 @@ Parameters:
...
@@ -499,6 +504,7 @@ Parameters:
-
`public`
(optional) - if
`true`
same as setting visibility_level = 20
-
`public`
(optional) - if
`true`
same as setting visibility_level = 20
-
`visibility_level`
(optional)
-
`visibility_level`
(optional)
-
`public_builds`
(optional)
-
`public_builds`
(optional)
-
`only_allow_merge_if_build_succeeds`
(optional)
On success, method returns 200 with the updated project. If parameters are
On success, method returns 200 with the updated project. If parameters are
invalid, 400 is returned.
invalid, 400 is returned.
...
@@ -577,7 +583,8 @@ Example response:
...
@@ -577,7 +583,8 @@ Example response:
"forks_count"
:
0
,
"forks_count"
:
0
,
"star_count"
:
1
,
"star_count"
:
1
,
"public_builds"
:
true
,
"public_builds"
:
true
,
"shared_with_groups"
:
[]
"shared_with_groups"
:
[],
"only_allow_merge_if_build_succeeds"
:
false
}
}
```
```
...
@@ -643,7 +650,8 @@ Example response:
...
@@ -643,7 +650,8 @@ Example response:
"forks_count"
:
0
,
"forks_count"
:
0
,
"star_count"
:
0
,
"star_count"
:
0
,
"public_builds"
:
true
,
"public_builds"
:
true
,
"shared_with_groups"
:
[]
"shared_with_groups"
:
[],
"only_allow_merge_if_build_succeeds"
:
false
}
}
```
```
...
@@ -729,7 +737,8 @@ Example response:
...
@@ -729,7 +737,8 @@ Example response:
"star_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8bc4a7a29eb76ea83cf79e4908c2b"
,
"runners_token"
:
"b8bc4a7a29eb76ea83cf79e4908c2b"
,
"public_builds"
:
true
,
"public_builds"
:
true
,
"shared_with_groups"
:
[]
"shared_with_groups"
:
[],
"only_allow_merge_if_build_succeeds"
:
false
}
}
```
```
...
@@ -815,7 +824,8 @@ Example response:
...
@@ -815,7 +824,8 @@ Example response:
"star_count"
:
0
,
"star_count"
:
0
,
"runners_token"
:
"b8bc4a7a29eb76ea83cf79e4908c2b"
,
"runners_token"
:
"b8bc4a7a29eb76ea83cf79e4908c2b"
,
"public_builds"
:
true
,
"public_builds"
:
true
,
"shared_with_groups"
:
[]
"shared_with_groups"
:
[],
"only_allow_merge_if_build_succeeds"
:
false
}
}
```
```
...
...
lib/api/entities.rb
View file @
31b2c1ef
...
@@ -90,6 +90,7 @@ module API
...
@@ -90,6 +90,7 @@ module API
expose
:shared_with_groups
do
|
project
,
options
|
expose
:shared_with_groups
do
|
project
,
options
|
SharedGroup
.
represent
(
project
.
project_group_links
.
all
,
options
)
SharedGroup
.
represent
(
project
.
project_group_links
.
all
,
options
)
end
end
expose
:only_allow_merge_if_build_succeeds
end
end
class
Member
<
UserBasic
class
Member
<
UserBasic
...
...
lib/api/projects.rb
View file @
31b2c1ef
...
@@ -123,7 +123,8 @@ module API
...
@@ -123,7 +123,8 @@ module API
:public
,
:public
,
:visibility_level
,
:visibility_level
,
:import_url
,
:import_url
,
:public_builds
]
:public_builds
,
:only_allow_merge_if_build_succeeds
]
attrs
=
map_public_to_visibility_level
(
attrs
)
attrs
=
map_public_to_visibility_level
(
attrs
)
@project
=
::
Projects
::
CreateService
.
new
(
current_user
,
attrs
).
execute
@project
=
::
Projects
::
CreateService
.
new
(
current_user
,
attrs
).
execute
if
@project
.
saved?
if
@project
.
saved?
...
@@ -172,7 +173,8 @@ module API
...
@@ -172,7 +173,8 @@ module API
:public
,
:public
,
:visibility_level
,
:visibility_level
,
:import_url
,
:import_url
,
:public_builds
]
:public_builds
,
:only_allow_merge_if_build_succeeds
]
attrs
=
map_public_to_visibility_level
(
attrs
)
attrs
=
map_public_to_visibility_level
(
attrs
)
@project
=
::
Projects
::
CreateService
.
new
(
user
,
attrs
).
execute
@project
=
::
Projects
::
CreateService
.
new
(
user
,
attrs
).
execute
if
@project
.
saved?
if
@project
.
saved?
...
@@ -234,7 +236,8 @@ module API
...
@@ -234,7 +236,8 @@ module API
:shared_runners_enabled
,
:shared_runners_enabled
,
:public
,
:public
,
:visibility_level
,
:visibility_level
,
:public_builds
]
:public_builds
,
:only_allow_merge_if_build_succeeds
]
attrs
=
map_public_to_visibility_level
(
attrs
)
attrs
=
map_public_to_visibility_level
(
attrs
)
authorize_admin_project
authorize_admin_project
authorize!
:rename_project
,
user_project
if
attrs
[
:name
].
present?
authorize!
:rename_project
,
user_project
if
attrs
[
:name
].
present?
...
...
spec/javascripts/fixtures/projects.json
View file @
31b2c1ef
This diff is collapsed.
Click to expand it.
spec/requests/api/projects_spec.rb
View file @
31b2c1ef
...
@@ -224,7 +224,8 @@ describe API::API, api: true do
...
@@ -224,7 +224,8 @@ describe API::API, api: true do
description:
FFaker
::
Lorem
.
sentence
,
description:
FFaker
::
Lorem
.
sentence
,
issues_enabled:
false
,
issues_enabled:
false
,
merge_requests_enabled:
false
,
merge_requests_enabled:
false
,
wiki_enabled:
false
wiki_enabled:
false
,
only_allow_merge_if_build_succeeds:
false
})
})
post
api
(
'/projects'
,
user
),
project
post
api
(
'/projects'
,
user
),
project
...
@@ -276,6 +277,18 @@ describe API::API, api: true do
...
@@ -276,6 +277,18 @@ describe API::API, api: true do
expect
(
json_response
[
'visibility_level'
]).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
expect
(
json_response
[
'visibility_level'
]).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
end
it
'sets a project as allowing merge even if build fails'
do
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_build_succeeds:
false
})
post
api
(
'/projects'
,
user
),
project
expect
(
json_response
[
'only_allow_merge_if_build_succeeds'
]).
to
be_falsey
end
it
'sets a project as allowing merge only if build succeeds'
do
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_build_succeeds:
true
})
post
api
(
'/projects'
,
user
),
project
expect
(
json_response
[
'only_allow_merge_if_build_succeeds'
]).
to
be_truthy
end
context
'when a visibility level is restricted'
do
context
'when a visibility level is restricted'
do
before
do
before
do
@project
=
attributes_for
(
:project
,
{
public:
true
})
@project
=
attributes_for
(
:project
,
{
public:
true
})
...
@@ -384,6 +397,18 @@ describe API::API, api: true do
...
@@ -384,6 +397,18 @@ describe API::API, api: true do
expect
(
json_response
[
'public'
]).
to
be_falsey
expect
(
json_response
[
'public'
]).
to
be_falsey
expect
(
json_response
[
'visibility_level'
]).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
expect
(
json_response
[
'visibility_level'
]).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
end
it
'sets a project as allowing merge even if build fails'
do
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_build_succeeds:
false
})
post
api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
project
expect
(
json_response
[
'only_allow_merge_if_build_succeeds'
]).
to
be_falsey
end
it
'sets a project as allowing merge only if build succeeds'
do
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_build_succeeds:
true
})
post
api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
project
expect
(
json_response
[
'only_allow_merge_if_build_succeeds'
]).
to
be_truthy
end
end
end
describe
"POST /projects/:id/uploads"
do
describe
"POST /projects/:id/uploads"
do
...
@@ -444,6 +469,7 @@ describe API::API, api: true do
...
@@ -444,6 +469,7 @@ describe API::API, api: true do
expect
(
json_response
[
'shared_with_groups'
][
0
][
'group_id'
]).
to
eq
(
group
.
id
)
expect
(
json_response
[
'shared_with_groups'
][
0
][
'group_id'
]).
to
eq
(
group
.
id
)
expect
(
json_response
[
'shared_with_groups'
][
0
][
'group_name'
]).
to
eq
(
group
.
name
)
expect
(
json_response
[
'shared_with_groups'
][
0
][
'group_name'
]).
to
eq
(
group
.
name
)
expect
(
json_response
[
'shared_with_groups'
][
0
][
'group_access_level'
]).
to
eq
(
link
.
group_access
)
expect
(
json_response
[
'shared_with_groups'
][
0
][
'group_access_level'
]).
to
eq
(
link
.
group_access
)
expect
(
json_response
[
'only_allow_merge_if_build_succeeds'
]).
to
eq
(
project
.
only_allow_merge_if_build_succeeds
)
end
end
it
'returns a project by path name'
do
it
'returns a project by path name'
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