< prev index next > bots/notify/src/main/java/org/openjdk/skara/bots/notify/MailingListUpdater.java
Print this page
this.mode = mode;
this.headers = headers;
this.allowedAuthorDomains = allowedAuthorDomains;
}
- private String patchToText(Patch patch) {
- if (patch.status().isAdded()) {
- return "+ " + patch.target().path().orElseThrow();
- } else if (patch.status().isDeleted()) {
- return "- " + patch.source().path().orElseThrow();
- } else if (patch.status().isModified()) {
- return "! " + patch.target().path().orElseThrow();
- } else {
- return "= " + patch.target().path().orElseThrow();
- }
- }
-
- private String commitToTextBrief(HostedRepository repository, Commit commit) {
- var writer = new StringWriter();
- var printer = new PrintWriter(writer);
-
- printer.println("Changeset: " + commit.hash().abbreviate());
- printer.println("Author: " + commit.author().name() + " <" + commit.author().email() + ">");
- if (!commit.author().equals(commit.committer())) {
- printer.println("Committer: " + commit.committer().name() + " <" + commit.committer().email() + ">");
- }
- printer.println("Date: " + commit.date().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss +0000")));
- printer.println("URL: " + repository.webUrl(commit.hash()));
-
- return writer.toString();
- }
-
- private String commitToText(HostedRepository repository, Commit commit) {
- var writer = new StringWriter();
- var printer = new PrintWriter(writer);
-
- printer.print(commitToTextBrief(repository, commit));
- printer.println();
- printer.println(String.join("\n", commit.message()));
- printer.println();
-
- for (var diff : commit.parentDiffs()) {
- for (var patch : diff.patches()) {
- printer.println(patchToText(patch));
- }
- }
-
- return writer.toString();
- }
-
private String tagAnnotationToText(HostedRepository repository, Tag.Annotated annotation) {
var writer = new StringWriter();
var printer = new PrintWriter(writer);
printer.println("Tagged by: " + annotation.author().name() + " <" + annotation.author().email() + ">");
ret.add(commit);
continue;
}
var rfr = rfrCandidates.get(0);
- var body = commitToText(repository, commit);
+ var body = CommitFormatters.commitToText(repository, commit);
var email = Email.reply(rfr, "Re: [Integrated] " + rfr.subject(), body)
.sender(sender)
.author(commitToAuthor(commit))
.recipient(recipient)
.headers(headers)
var writer = new StringWriter();
var printer = new PrintWriter(writer);
for (var commit : commits) {
- printer.println(commitToText(repository, commit));
+ printer.println(CommitFormatters.commitToText(repository, commit));
}
var subject = commitsToSubject(repository, commits, branch);
var lastCommit = commits.get(commits.size() - 1);
var commitAddress = filteredAuthor(EmailAddress.from(lastCommit.committer().name(), lastCommit.committer().email()));
var taggedCommit = commits.get(commits.size() - 1);
if (annotation != null) {
printer.println(tagAnnotationToText(repository, annotation));
}
- printer.println(commitToTextBrief(repository, taggedCommit));
+ printer.println(CommitFormatters.commitToTextBrief(repository, taggedCommit));
printer.println("The following commits are included in " + tag.tag());
printer.println("========================================================");
for (var commit : commits) {
printer.print(commit.hash().abbreviate());
var printer = new PrintWriter(writer);
if (annotation != null) {
printer.println(tagAnnotationToText(repository, annotation));
}
- printer.println(commitToTextBrief(repository, commit));
+ printer.println(CommitFormatters.commitToTextBrief(repository, commit));
var subject = tagToSubject(repository, commit.hash(), tag);
var email = Email.create(subject, writer.toString())
.sender(sender)
.recipient(recipient)
< prev index next >