Include a quick summary of the size of a change in email
Including tabular formatted text in an email can be ugly, many
user agents just use a proportional width font and assume that is
sufficient. So instead of using a table to display the damage to
each file, just display a summary at the bottom of the file listing.
It will at least give a reviewer a notion of the length of time
they might need to review the change.
Bug: issue 452
Change-Id: I3bbf1da2058ed51e363cff045d3e196323bce333
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/mail/ChangeEmail.java b/gerrit-server/src/main/java/com/google/gerrit/server/mail/ChangeEmail.java
index dcce60e..b3ddaeb 100644
--- a/gerrit-server/src/main/java/com/google/gerrit/server/mail/ChangeEmail.java
+++ b/gerrit-server/src/main/java/com/google/gerrit/server/mail/ChangeEmail.java
@@ -35,6 +35,7 @@
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
import com.google.gwtorm.client.OrmException;
+import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -277,12 +278,20 @@
if (patchSet != null) {
appendText("---\n");
- for (PatchListEntry p : getPatchList().getPatches()) {
+ PatchList patchList = getPatchList();
+ for (PatchListEntry p : patchList.getPatches()) {
if (Patch.COMMIT_MSG.equals(p.getNewName())) {
continue;
}
appendText(p.getChangeType().getCode() + " " + p.getNewName() + "\n");
}
+ appendText(MessageFormat.format("" //
+ + "{0,choice,0#0 files|1#1 file|1<{0} files} changed, " //
+ + "{1,choice,0#0 insertions|1#1 insertion|1<{1} insertions}(+), " //
+ + "{2,choice,0#0 deletions|1#1 deletion|1<{2} deletions}(-)" //
+ + "\n", patchList.getPatches().size() - 1, //
+ patchList.getInsertions(), //
+ patchList.getDeletions()));
appendText("\n");
}
}