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

Add checkout instructions to PR body #434

Closed
wants to merge 6 commits 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
@@ -302,7 +302,8 @@ private Optional<String> getContributorsList(List<Comment> comments) {

private String getStatusMessage(List<Comment> comments, List<Review> reviews, PullRequestCheckIssueVisitor visitor) {
var progressBody = new StringBuilder();
progressBody.append("## Progress\n");
progressBody.append("---------");
progressBody.append("### Progress\n");
progressBody.append(getChecksList(visitor));

var issue = Issue.fromString(pr.title());
@@ -311,13 +312,14 @@ private String getStatusMessage(List<Comment> comments, List<Review> reviews, Pu
var allIssues = new ArrayList<Issue>();
allIssues.add(issue.get());
allIssues.addAll(SolvesTracker.currentSolved(pr.repository().forge().currentUser(), comments));
progressBody.append("\n\n## Issue");
progressBody.append("\n\n### Issue");
if (allIssues.size() > 1) {
progressBody.append("s");
}
progressBody.append("\n");
for (var currentIssue : allIssues) {
var iss = issueProject.issue(currentIssue.id());
progressBody.append(" * ");
if (iss.isPresent()) {
progressBody.append("[");
progressBody.append(iss.get().id());
@@ -335,18 +337,28 @@ private String getStatusMessage(List<Comment> comments, List<Review> reviews, Pu
}

getReviewersList(reviews).ifPresent(reviewers -> {
progressBody.append("\n\n## Reviewers\n");
progressBody.append("\n\n### Reviewers\n");
progressBody.append(reviewers);
});

getContributorsList(comments).ifPresent(contributors -> {
progressBody.append("\n\n## Contributors\n");
progressBody.append("\n\n### Contributors\n");
progressBody.append(contributors);
});

progressBody.append("\n\n### Download\n");
progressBody.append(checkoutCommands());

return progressBody.toString();
}

private String checkoutCommands() {
var repoUrl = pr.repository().webUrl();
return
"`$ git fetch " + repoUrl + " " + pr.fetchRef() + ":pull/" + pr.id() + "`\n" +
"`$ git checkout pull/" + pr.id() + "`\n";
}

private String updateStatusMessage(String message) {
var description = pr.body();
var markerIndex = description.lastIndexOf(progressMarker);
@@ -332,7 +332,7 @@ void prBodyUpdates(TestInfo testInfo) throws IOException {
var contributorsHeaderIndex = -1;
for (var i = 0; i < body.length; i++) {
var line = body[i];
if (line.equals("## Contributors")) {
if (line.equals("### Contributors")) {
contributorsHeaderIndex = i;
break;
}
@@ -352,7 +352,7 @@ void prBodyUpdates(TestInfo testInfo) throws IOException {

// Verify that body does not contain "Contributors" section
for (var line : pr.body().split("\n")) {
assertNotEquals("## Contributors", line);
assertNotEquals("### Contributors", line);
}
}
}