Skip to content
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

309: Backport creation fails #511

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -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())));