Skip to content
Permalink
Browse files
1194: Implement git webrev --no-comments option
Reviewed-by: erikj, ihse
  • Loading branch information
shipilev authored and magicus committed Sep 30, 2021
1 parent 91be684 commit 68872aa293fc7ec21cfcd88a0b4fdd159e5546f8
@@ -259,6 +259,8 @@ private static void generate(String[] args) throws IOException {
}
}

var comments = !arguments.contains("no-comments");

if (arguments.contains("base") && arguments.contains("rev")) {
System.err.println("error: cannot combine --base and --rev options");
System.exit(1);
@@ -449,6 +451,7 @@ private static void generate(String[] args) throws IOException {
.version(version)
.files(files)
.similarity(similarity)
.comments(comments)
.generate(base, head);
}
}
@@ -125,11 +125,13 @@ public void render(Writer w) throws IOException {

if (patch.isTextual()) {
w.write("<blockquote>\n");
w.write(" <pre>\n");
w.write(commits.stream()
.map(formatter::format)
.collect(Collectors.joining("\n")));
w.write(" </pre>\n");
if (!commits.isEmpty()) {
w.write(" <pre>\n");
w.write(commits.stream()
.map(formatter::format)
.collect(Collectors.joining("\n")));
w.write(" </pre>\n");
}
w.write(" <span class=\"stat\">\n");
w.write(stats.toString());
w.write(" </span>");
@@ -192,11 +192,13 @@ public void render(Writer w) throws IOException {

if (patch.isTextual()) {
w.write("<blockquote>\n");
w.write(" <pre>\n");
w.write(commits.stream()
.map(formatter::format)
.collect(Collectors.joining("\n")));
w.write(" </pre>\n");
if (!commits.isEmpty()) {
w.write(" <pre>\n");
w.write(commits.stream()
.map(formatter::format)
.collect(Collectors.joining("\n")));
w.write(" </pre>\n");
}
w.write(" <span class=\"stat\">\n");
w.write(stats.toString());
w.write(" </span>");
@@ -102,11 +102,13 @@ public void render(Writer w) throws IOException {

if (patch.isTextual()) {
w.write("<blockquote>\n");
w.write(" <pre>\n");
w.write(commits.stream()
.map(formatter::format)
.collect(Collectors.joining("\n")));
w.write(" </pre>\n");
if (!commits.isEmpty()) {
w.write(" <pre>\n");
w.write(commits.stream()
.map(formatter::format)
.collect(Collectors.joining("\n")));
w.write(" </pre>\n");
}
w.write(" <span class=\"stat\">\n");
w.write(stats.toString());
w.write(" </span>");
@@ -84,6 +84,7 @@ public static class Builder {
private String version;
private List<Path> files = List.of();
private int similarity = 90;
private boolean comments;

Builder(ReadOnlyRepository repository, Path output) {
this.repository = repository;
@@ -162,6 +163,11 @@ public Builder similarity(int similarity) {
return this;
}

public Builder comments(boolean comments) {
this.comments = comments;
return this;
}

public void generate(Hash tailEnd) throws IOException {
generate(tailEnd, null);
}
@@ -384,7 +390,7 @@ private void generate(Diff diff, Hash tailEnd, Hash head) throws IOException {
var path = status.isDeleted() ?
patch.source().path().get() :
patch.target().path().get();
var commits = repository.commitMetadata(tailEnd, headHash, List.of(path));
var commits = comments ? repository.commitMetadata(tailEnd, headHash, List.of(path)) : Collections.<CommitMetadata>emptyList();
if (status.isModified() || status.isRenamed() || status.isCopied()) {
var nav = navigations.removeFirst();
fileViews.add(new ModifiedFileView(repository, tailEnd, head, commits, formatter, patch, output, nav));

1 comment on commit 68872aa

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 68872aa Sep 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.