Skip to content
Permalink
Browse files
309: Backport creation fails
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Mar 16, 2020
1 parent 27793d2 commit 6468f17b3dbc025e47dc5234712f74e661a33023
Showing 2 changed files with 8 additions and 9 deletions.
@@ -33,7 +33,7 @@
import java.util.*;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.*;

public class RepositoryWorkItem implements WorkItem {
private final Logger log = Logger.getLogger("org.openjdk.skara.bots");;
@@ -288,7 +288,7 @@ public void run(Path scratchPath) {
}
if (!errors.isEmpty()) {
errors.forEach(error -> log.throwing("RepositoryWorkItem", "run", error));
throw new RuntimeException("Errors detected when processing repository notifications");
throw new RuntimeException("Errors detected when processing repository notifications", errors.get(0));
}
} catch (IOException e) {
throw new UncheckedIOException(e);
@@ -220,14 +220,8 @@ private JSONValue filterCustomFieldValue(String name, JSONValue unfiltered) {
public Issue createIssue(String title, List<String> body, Map<String, JSONValue> properties) {
var query = JSON.object();

var finalProperties = new HashMap<String, JSONValue>(properties);

// Always override certain fields
finalProperties.put("project", JSON.object().put("id", projectId()));
finalProperties.put("summary", JSON.of(title));
finalProperties.put("description", JSON.of(String.join("\n", body)));

// Encode optional properties as fields
var finalProperties = new HashMap<String, JSONValue>();
for (var property : properties.entrySet()) {
var encoded = encodeProperty(property.getKey(), property.getValue());
if (encoded.isEmpty()) {
@@ -236,6 +230,11 @@ public Issue createIssue(String title, List<String> body, Map<String, JSONValue>
finalProperties.put(property.getKey(), encoded.get());
}

// Always override certain fields
finalProperties.put("project", JSON.object().put("id", projectId()));
finalProperties.put("summary", JSON.of(title));
finalProperties.put("description", JSON.of(String.join("\n", body)));

// Provide default values for required fields if not present
finalProperties.putIfAbsent("components", JSON.array().add(JSON.object().put("id", defaultComponent())));

0 comments on commit 6468f17

Please sign in to comment.