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

372: Tool support for small/minor/trivial "fast-track" changes. #677

Closed
wants to merge 6 commits into from
Closed
Changes from 2 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
@@ -59,15 +59,15 @@ private void showHelp(PrintWriter reply) {
reply.println("Command syntax:");
reply.println(" * `/" + name + " [add|remove] <id>[,<id>,...]`");
reply.println(" * `/" + name + " [add] <id>: <description>`");
reply.println(" * `/" + name + " create [pX] [type] <component> [subcomponent]");
reply.println(" * `/" + name + " create [pX] <component> [subcomponent]");
rwestberg marked this conversation as resolved.
Show resolved Hide resolved
reply.println();
reply.println("Some examples:");
reply.println();
reply.println(" * `/" + name + " add JDK-1234567,4567890`");
reply.println(" * `/" + name + " remove JDK-4567890`");
reply.println(" * `/" + name + " 1234567: Use this exact title`");
reply.println(" * `/" + name + " create hotspot jfr");
rwestberg marked this conversation as resolved.
Show resolved Hide resolved
reply.println(" * `/" + name + " create P4 enhancement core-libs java.nio");
reply.println(" * `/" + name + " create P4 core-libs java.nio");
rwestberg marked this conversation as resolved.
Show resolved Hide resolved
reply.println();
reply.print("If issues are specified only by their ID, the title will be automatically retrieved from JBS. ");
reply.print("The project prefix (`JDK-` in the above examples) is optional. ");
@@ -212,8 +212,6 @@ private void removeIssue(PullRequestBot bot, String args, Set<String> currentSol
}
}

private static final Set<String> allowedTypes = Set.of("bug", "new", "enhancement");

private void createIssue(PullRequestBot bot, PullRequest pr, String args, CensusInstance censusInstance, HostUser author, PrintWriter reply) {
if (!censusInstance.isAuthor(author)) {
edvbld marked this conversation as resolved.
Show resolved Hide resolved
reply.println("Only [Authors](https://openjdk.java.net/bylaws#author) are allowed to create issues.");
@@ -226,11 +224,10 @@ private void createIssue(PullRequestBot bot, PullRequest pr, String args, Census
return;
}

var argSplit = new LinkedList<>(Arrays.asList(args.split("\\s+")));
var argSplit = new LinkedList<>(Arrays.asList(args.split("(?:\\s+|/)")));
argSplit.pollFirst();

String priority = null;
String type = null;
String subComponent = null;

// First argument can be a priority
@@ -240,23 +237,6 @@ private void createIssue(PullRequestBot bot, PullRequest pr, String args, Census
next = argSplit.pollFirst();
}

// Second (and third) can be a known issue type
if (next != null && allowedTypes.contains(next.toLowerCase())) {
if (next.equals("new")) {
next = argSplit.pollFirst();
if (next != null && next.toLowerCase().equals("feature")) {
type = "new feature";
} else {
// Undo the halfway mismatch
argSplit.offerFirst(next);
argSplit.offerFirst("new");
}
} else {
type = next.toLowerCase();
}
next = argSplit.pollFirst();
}

// Next argument is the mandatory component name
if (next == null) {
showHelp(reply);
@@ -278,9 +258,7 @@ private void createIssue(PullRequestBot bot, PullRequest pr, String args, Census
if (priority != null) {
properties.put("priority", JSON.of(priority));
}
if (type != null) {
properties.put("issuetype", JSON.of(type));
}
properties.put("issuetype", JSON.of("enhancement"));

var bodyText = PullRequestBody.parse(pr).bodyText();
try {
@@ -472,7 +472,7 @@ void createIssueParameterized(TestInfo testInfo) throws IOException {
pr.setTitle("This is another pull request");

// Create an issue
pr.addComment("/issue create P4 enhancement hotspot");
pr.addComment("/issue create P4 hotspot");
TestBotRunner.runPeriodicItems(prBot);

// Verify it
@@ -486,14 +486,14 @@ void createIssueParameterized(TestInfo testInfo) throws IOException {
pr.setTitle("This is yet another pull request");

// Create an issue
pr.addComment("/issue create new feature core-libs java.io");
pr.addComment("/issue create core-libs/java.io");
TestBotRunner.runPeriodicItems(prBot);

// Verify it
issue = issueFromLastComment(pr, issues);
assertEquals("This is yet another pull request", issue.title());
assertEquals("core-libs", issue.properties().get("components").asArray().get(0).asString());
assertEquals("new feature", issue.properties().get("issuetype").asString().toLowerCase());
assertEquals("enhancement", issue.properties().get("issuetype").asString().toLowerCase());
assertEquals("java.io", issue.properties().get("customfield_10008").asString());
}
}
@@ -245,7 +245,6 @@ JSONValue encodeCustomFields(String name, JSONValue value, Map<String, JSONValue
.findAny().orElseThrow()
.get("fields")
.asObject();
System.out.println("Allowed fields " + fields);

var field = fields.get(name);
var componentIds = allProperties.get("components").stream()