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

SKARA-1194: Implement git webrev --no-comments option #1224

Closed
Closed
Show file tree
Hide file tree
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
@@ -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));