< prev index next >

bots/pr/src/main/java/org/openjdk/skara/bots/pr/PullRequestInstance.java

Print this page

 64         }
 65         return new ArrayList<>(reviewPerUser.values());
 66     }
 67 
 68     private String commitMessage(List<Review> activeReviews, Namespace namespace, boolean isMerge) throws IOException {
 69         var reviewers = activeReviews.stream()
 70                           .filter(review -> review.verdict() == Review.Verdict.APPROVED)
 71                           .map(review -> review.reviewer().id())
 72                           .map(namespace::get)
 73                           .filter(Objects::nonNull)
 74                           .map(Contributor::username)
 75                           .collect(Collectors.toList());
 76 
 77         var comments = pr.getComments();
 78         var additionalContributors = Contributors.contributors(pr.repository().host().getCurrentUserDetails(),
 79                                                                comments).stream()
 80                                                  .map(email -> Author.fromString(email.toString()))
 81                                                  .collect(Collectors.toList());
 82 
 83         var summary = Summary.summary(pr.repository().host().getCurrentUserDetails(), comments);
 84 
 85         var commitMessage = CommitMessage.title(isMerge ? "Merge" : pr.getTitle())
 86                                          .contributors(additionalContributors)
 87                                          .reviewers(reviewers);
 88         summary.ifPresent(commitMessage::summary);
 89 
 90         return String.join("\n", commitMessage.format(CommitMessageFormatters.v1));
 91     }
 92 
 93     private Hash commitSquashed(List<Review> activeReviews, Namespace namespace, String censusDomain, String sponsorId) throws IOException {
 94         localRepo.checkout(baseHash, true);
 95         localRepo.squash(headHash);
 96 
 97         Author committer;
 98         Author author;
 99         var contributor = namespace.get(pr.getAuthor().id());
100 
101         if (contributor == null) {
102             // Use the information contained in the head commit - jcheck has verified that it contains sane values
103             var headCommit = localRepo.commits(headHash.hex() + "^.." + headHash.hex()).asList().get(0);
104             author = headCommit.author();
105         } else {
106             author = new Author(contributor.fullName().orElseThrow(), contributor.username() + "@" + censusDomain);
107         }
108 
109         if (sponsorId != null) {
110             var sponsorContributor = namespace.get(sponsorId);

 64         }
 65         return new ArrayList<>(reviewPerUser.values());
 66     }
 67 
 68     private String commitMessage(List<Review> activeReviews, Namespace namespace, boolean isMerge) throws IOException {
 69         var reviewers = activeReviews.stream()
 70                           .filter(review -> review.verdict() == Review.Verdict.APPROVED)
 71                           .map(review -> review.reviewer().id())
 72                           .map(namespace::get)
 73                           .filter(Objects::nonNull)
 74                           .map(Contributor::username)
 75                           .collect(Collectors.toList());
 76 
 77         var comments = pr.getComments();
 78         var additionalContributors = Contributors.contributors(pr.repository().host().getCurrentUserDetails(),
 79                                                                comments).stream()
 80                                                  .map(email -> Author.fromString(email.toString()))
 81                                                  .collect(Collectors.toList());
 82 
 83         var summary = Summary.summary(pr.repository().host().getCurrentUserDetails(), comments);
 84         var issue = Issue.fromString(pr.getTitle());
 85         var commitMessageBuilder = issue.map(CommitMessage::title).orElseGet(() -> CommitMessage.title(isMerge ? "Merge" : pr.getTitle()));
 86         commitMessageBuilder.contributors(additionalContributors)
 87                                          .reviewers(reviewers);
 88         summary.ifPresent(commitMessageBuilder::summary);
 89 
 90         return String.join("\n", commitMessageBuilder.format(CommitMessageFormatters.v1));
 91     }
 92 
 93     private Hash commitSquashed(List<Review> activeReviews, Namespace namespace, String censusDomain, String sponsorId) throws IOException {
 94         localRepo.checkout(baseHash, true);
 95         localRepo.squash(headHash);
 96 
 97         Author committer;
 98         Author author;
 99         var contributor = namespace.get(pr.getAuthor().id());
100 
101         if (contributor == null) {
102             // Use the information contained in the head commit - jcheck has verified that it contains sane values
103             var headCommit = localRepo.commits(headHash.hex() + "^.." + headHash.hex()).asList().get(0);
104             author = headCommit.author();
105         } else {
106             author = new Author(contributor.fullName().orElseThrow(), contributor.username() + "@" + censusDomain);
107         }
108 
109         if (sponsorId != null) {
110             var sponsorContributor = namespace.get(sponsorId);
< prev index next >