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
a7be1582
Commit
a7be1582
authored
Aug 27, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
975e7030
a390f5ff
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
115 additions
and
2 deletions
+115
-2
changelogs/unreleased/57657-promote-label-to-group-label-via-api-endpoint.yml
...d/57657-promote-label-to-group-label-via-api-endpoint.yml
+5
-0
doc/api/labels.md
doc/api/labels.md
+34
-0
doc/development/feature_flags/index.md
doc/development/feature_flags/index.md
+2
-2
lib/api/labels.rb
lib/api/labels.rb
+25
-0
spec/requests/api/labels_spec.rb
spec/requests/api/labels_spec.rb
+49
-0
No files found.
changelogs/unreleased/57657-promote-label-to-group-label-via-api-endpoint.yml
0 → 100644
View file @
a7be1582
---
title
:
'
API:
Promote
project
labels
to
group
labels'
merge_request
:
25218
author
:
Robert Schilling
type
:
added
doc/api/labels.md
View file @
a7be1582
...
...
@@ -186,6 +186,40 @@ Example response:
}
```
## Promote a project label to a group label
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/25218) in GitLab 12.3.
Promotes a project label to a group label.
```
PUT /projects/:id/labels/promote
```
| Attribute | Type | Required | Description |
| --------------- | ------- | --------------------------------- | ------------------------------- |
|
`id`
| integer/string | yes | The ID or
[
URL-encoded path of the project
](
README.md#namespaced-path-encoding
)
owned by the authenticated user |
|
`name`
| string | yes | The name of the existing label |
```
bash
curl
--request
PUT
--data
"name=documentation"
--header
"PRIVATE-TOKEN: <your_access_token>"
"https://gitlab.example.com/api/v4/projects/1/labels/promote"
```
Example response:
```
json
{
"id"
:
8
,
"name"
:
"documentation"
,
"color"
:
"#8E44AD"
,
"description"
:
"Documentation"
,
"open_issues_count"
:
1
,
"closed_issues_count"
:
0
,
"open_merge_requests_count"
:
2
,
"subscribed"
:
false
}
```
## Subscribe to a label
Subscribes the authenticated user to a label to receive notifications.
...
...
doc/development/feature_flags/index.md
View file @
a7be1582
...
...
@@ -8,5 +8,5 @@ disable those changes, without having to revert an entire release.
Before using feature flags for GitLab's development, read through the following:
-
[
Process for using features flags
](
process.md
)
.
-
[
Developing with feature flags
documentation
](
development.md
)
.
-
[
Controlling feature flags
documentation
](
controls.md
)
.
-
[
Developing with feature flags
](
development.md
)
.
-
[
Controlling feature flags
](
controls.md
)
.
lib/api/labels.rb
View file @
a7be1582
...
...
@@ -62,6 +62,31 @@ module API
delete
':id/labels'
do
delete_label
(
user_project
)
end
desc
'Promote a label to a group label'
do
detail
'This feature was added in GitLab 12.3'
success
Entities
::
GroupLabel
end
params
do
requires
:name
,
type:
String
,
desc:
'The name of the label to be promoted'
end
put
':id/labels/promote'
do
authorize!
:admin_label
,
user_project
label
=
find_label
(
user_project
,
params
[
:name
],
include_ancestor_groups:
false
)
begin
group_label
=
::
Labels
::
PromoteService
.
new
(
user_project
,
current_user
).
execute
(
label
)
if
group_label
present
group_label
,
with:
Entities
::
GroupLabel
,
current_user:
current_user
,
parent:
user_project
.
group
else
render_api_error!
(
'Failed to promote project label to group label'
,
400
)
end
rescue
=>
error
render_api_error!
(
error
.
to_s
,
400
)
end
end
end
end
end
spec/requests/api/labels_spec.rb
View file @
a7be1582
...
...
@@ -473,6 +473,55 @@ describe API::Labels do
end
end
describe
'PUT /projects/:id/labels/promote'
do
let
(
:group
)
{
create
(
:group
)
}
before
do
group
.
add_owner
(
user
)
project
.
update!
(
group:
group
)
end
it
'returns 200 if label is promoted'
do
put
api
(
"/projects/
#{
project
.
id
}
/labels/promote"
,
user
),
params:
{
name:
label1
.
name
}
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
json_response
[
'name'
]).
to
eq
(
label1
.
name
)
expect
(
json_response
[
'color'
]).
to
eq
(
label1
.
color
)
end
it
'returns 200 if group label already exists'
do
create
(
:group_label
,
title:
label1
.
name
,
group:
group
)
expect
{
put
api
(
"/projects/
#{
project
.
id
}
/labels/promote"
,
user
),
params:
{
name:
label1
.
name
}
}
.
to
change
(
project
.
labels
,
:count
).
by
(
-
1
)
.
and
change
(
group
.
labels
,
:count
).
by
(
0
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
end
it
'returns 403 if guest promotes label'
do
guest
=
create
(
:user
)
project
.
add_guest
(
guest
)
put
api
(
"/projects/
#{
project
.
id
}
/labels/promote"
,
guest
),
params:
{
name:
label1
.
name
}
expect
(
response
).
to
have_gitlab_http_status
(
403
)
end
it
'returns 404 if label does not exist'
do
put
api
(
"/projects/
#{
project
.
id
}
/labels/promote"
,
user
),
params:
{
name:
'unknown'
}
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
it
'returns 400 if no label name given'
do
put
api
(
"/projects/
#{
project
.
id
}
/labels/promote"
,
user
)
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'error'
]).
to
eq
(
'name is missing'
)
end
end
describe
"POST /projects/:id/labels/:label_id/subscribe"
do
context
"when label_id is a label title"
do
it
"subscribes to the label"
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