-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing Labels via EditPullRequest API #5348
Conversation
…PI to remove all labels Signed-off-by: Lucien Kerl <lucien.kerl@wuerth-it.com>
Codecov Report
@@ Coverage Diff @@
## master #5348 +/- ##
=======================================
Coverage 37.56% 37.56%
=======================================
Files 317 317
Lines 46821 46821
=======================================
Hits 17590 17590
Misses 26732 26732
Partials 2499 2499
Continue to review full report at Codecov.
|
routers/api/v1/repo/pull.go
Outdated
@@ -405,7 +405,7 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) { | |||
} | |||
} | |||
|
|||
if ctx.Repo.IsWriter() && (form.Labels != nil && len(form.Labels) > 0) { | |||
if ctx.Repo.IsWriter() && form.Labels != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this remove all labels not provided in the request?
Example: I have 5 labels.
- Request: Add label 1,4,2
- Request: Add label 3
Would this then have 1,2,3,4 or only 3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this will remove all labels not provided in the request.
This would only have the label3 then.
Otherwise you would not be able to delete labels.
As adding labels by API was just merged and this is change is recent functionality I'm not adding breaking label for this |
Tests will be better. |
@lucienkerl file conflicted. |
routers/api/v1/repo/pull.go
Outdated
@@ -405,7 +405,8 @@ func EditPullRequest(ctx *context.APIContext, form api.EditPullRequestOption) { | |||
} | |||
} | |||
|
|||
if ctx.Repo.CanWrite(models.UnitTypePullRequests) && (form.Labels != nil && len(form.Labels) > 0) { | |||
if ctx.Repo.CanWrite(models.UnitTypePullRequests) && form.Labels != nil { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The blank line is unnecessary.
Because of a comment at the PR #5347 I recognized that it is currently not possible to remove labels.
This PR adds the ability to provide an empty labels array to remove all labels from a PR.