Skip to content
Permalink
Browse files
396: Add some additional help for empty PRs
Reviewed-by: jvernee
  • Loading branch information
rwestberg committed May 11, 2020
1 parent c558479 commit 052aee4263f6fabddf5ef7d59fc334768fb93027
Showing with 18 additions and 6 deletions.
  1. +12 −6 bots/pr/src/main/java/org/openjdk/skara/bots/pr/CheckRun.java
  2. +6 −0 bots/pr/src/test/java/org/openjdk/skara/bots/pr/CheckTests.java
@@ -50,11 +50,13 @@
private final Hash baseHash;
private final CheckablePullRequest checkablePullRequest;

private final Logger log = Logger.getLogger("org.openjdk.skara.bots.pr");
private final String progressMarker = "<!-- Anything below this marker will be automatically updated, please do not edit manually! -->";
private final String mergeReadyMarker = "<!-- PullRequestBot merge is ready comment -->";
private final String outdatedHelpMarker = "<!-- PullRequestBot outdated help comment -->";
private final String sourceBranchWarningMarker = "<!-- PullRequestBot source branch warning comment -->";
private static final Logger log = Logger.getLogger("org.openjdk.skara.bots.pr");
private static final String progressMarker = "<!-- Anything below this marker will be automatically updated, please do not edit manually! -->";
private static final String mergeReadyMarker = "<!-- PullRequestBot merge is ready comment -->";
private static final String outdatedHelpMarker = "<!-- PullRequestBot outdated help comment -->";
private static final String sourceBranchWarningMarker = "<!-- PullRequestBot source branch warning comment -->";
private static final String emptyPrBodyMarker = "<!--\nReplace this text with a description of your pull request (also remove the surrounding HTML comment markers).\n" +
"If in doubt, feel free to delete everything in this edit box first, the bot will restore the progress section as needed.\n-->";
private final Set<String> newLabels;

private CheckRun(CheckWorkItem workItem, PullRequest pr, Repository localRepo, List<Comment> comments,
@@ -361,7 +363,11 @@ private String updateStatusMessage(String message) {
log.info("Progress already up to date");
return description;
}
var newBody = bodyWithoutStatus() + "\n" + progressMarker + "\n" + message;
var originalBody = bodyWithoutStatus();
if (originalBody.isBlank()) {
originalBody = emptyPrBodyMarker;
}
var newBody = originalBody + "\n" + progressMarker + "\n" + message;

// TODO? Retrieve the body again here to lower the chance of concurrent updates
pr.setBody(newBody);
@@ -704,6 +704,9 @@ void emptyPRBody(TestInfo testInfo) throws IOException {
assertTrue(updatedPr.body().contains("## Error"));
assertTrue(updatedPr.body().contains("The pull request body must not be empty."));

// There should be an indicator of where the pr body should be entered
assertTrue(updatedPr.body().contains("Replace this text with a description of your pull request"));

// The PR should not yet be ready for review
assertFalse(pr.labels().contains("rfr"));
assertFalse(pr.labels().contains("ready"));
@@ -720,6 +723,9 @@ void emptyPRBody(TestInfo testInfo) throws IOException {
updatedPr = author.pullRequest(pr.id());
assertFalse(updatedPr.body().contains("## Error"));
assertFalse(updatedPr.body().contains("The pull request body must not be empty."));

// And no new helper marker
assertFalse(updatedPr.body().contains("Replace this text with a description of your pull request"));
}
}

0 comments on commit 052aee4

Please sign in to comment.