Support new label names containing colons
This commit is contained in:
@@ -19,6 +19,7 @@ package io.spring.issuebot.github;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -153,9 +154,16 @@ public class GitHubTemplate implements GitHubOperations {
|
||||
|
||||
@Override
|
||||
public Issue removeLabel(Issue issue, String labelName) {
|
||||
String encodedName;
|
||||
try {
|
||||
encodedName = new URI(null, null, labelName, null).toString();
|
||||
}
|
||||
catch (URISyntaxException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
ResponseEntity<Label[]> response = this.rest.exchange(
|
||||
new RequestEntity<Void>(HttpMethod.DELETE, URI.create(
|
||||
issue.getLabelsUrl().replace("{/name}", "/" + labelName))),
|
||||
issue.getLabelsUrl().replace("{/name}", "/" + encodedName))),
|
||||
Label[].class);
|
||||
if (response.getStatusCode() != HttpStatus.OK) {
|
||||
log.warn("Failed to remove label from issue. Response status: "
|
||||
|
||||
@@ -10,11 +10,11 @@ issuebot:
|
||||
- snicoll
|
||||
- wilkinsona
|
||||
triage:
|
||||
label: waiting-for-triage
|
||||
label: "status: waiting-for-triage"
|
||||
feedback:
|
||||
required_label: waiting-for-feedback
|
||||
provided_label: feedback-provided
|
||||
reminder_label: feedback-reminder
|
||||
required_label: "status: waiting-for-feedback"
|
||||
provided_label: "status: feedback-provided"
|
||||
reminder_label: "status: feedback-reminder"
|
||||
reminder_comment: >
|
||||
If you would like us to look at this issue, please provide the requested
|
||||
information. If the information is not provided within the next 7 days this issue
|
||||
|
||||
@@ -179,6 +179,17 @@ public class GitHubTemplateTests {
|
||||
assertThat(modifiedIssue.getLabels(), hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void removeLabelWithNameThatRequiresEncodingFromIssue() {
|
||||
this.server.expect(requestTo("labels/status:%20foo")).andExpect(method(HttpMethod.DELETE))
|
||||
.andExpect(basicAuth())
|
||||
.andRespond(withSuccess("[]", MediaType.APPLICATION_JSON));
|
||||
Issue issue = new Issue(null, null, null, "labels{/name}", null, null, null,
|
||||
null);
|
||||
Issue modifiedIssue = this.gitHub.removeLabel(issue, "status: foo");
|
||||
assertThat(modifiedIssue.getLabels(), hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addCommentToIssue() {
|
||||
this.server.expect(requestTo("commentsUrl")).andExpect(method(HttpMethod.POST))
|
||||
|
||||
Reference in New Issue
Block a user