[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [githax/master] Put commit numbers in our subject lines
commit a06692e929eb884d519ef90d10fc36b6d64006c0
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Sat Jan 15 17:51:18 2011 -0500
Put commit numbers in our subject lines
If you specify an environment variable TOTAL_N_COMMITS, the prefix
lines are of the form "123/456". If you don't, the numbers are just
of the form "#123".
---
hooks/logs_to_emails.pl | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diff --git a/hooks/logs_to_emails.pl b/hooks/logs_to_emails.pl
index b71416a..af62f78 100755
--- a/hooks/logs_to_emails.pl
+++ b/hooks/logs_to_emails.pl
@@ -19,6 +19,9 @@ use strict;
# Suggested use in a commit script:
my $suggested_use = q[
+ TOTAL_N_COMMITS=`git log --pretty=format:oneline "$oldrev..$newrev"`
+ export TOTAL_N_COMMITS
+
git log --reverse -p --stat --cc "$oldrev..$newrev" |
remove_empty_merges.pl |
logs_to_emails.pl "$projectname/${refname#refs/heads/}" |
@@ -27,20 +30,32 @@ my $suggested_use = q[
-s /usr/bin/sendmail -t
] ;
-# Deficiencies:
-# Doesn't do 003/231 counting in the subject line like format-patch does
+# Set the environment variable TOTAL_N_COMMITS if you want to get a
+# nice 001/123 header in your commits.
+my $NUM_COMMITS = $ENV{TOTAL_N_COMMITS} or "";
my $waiting_for_commit = 1;
my $prefix = shift @ARGV;
-if ($prefix) {
- $prefix = "[$prefix] ";
-} else {
- $prefix = "";
-}
my @headerlines;
my $commitnum;
my %headervals;
my $firsttime = 1;
+my $commit_idx = 0;
+
+sub getprefix {
+ my $curnum = shift @_;
+ my $extra;
+ if ($NUM_COMMITS eq "") {
+ $extra = "#$curnum";
+ } else {
+ $extra = sprintf("%03d/%03d", $curnum, $NUM_COMMITS);
+ }
+ if ($prefix) {
+ return "[$prefix $extra]";
+ } else {
+ return "[$extra]";
+ }
+}
while (<>) {
if ($waiting_for_commit) {
@@ -69,10 +84,12 @@ while (<>) {
print "\n\n" unless ($firsttime);
$firsttime = 0;
+ ++$commit_idx;
print "From $commitnum Mon Sep 17 00:00:00 2001\n";
print "From: $headervals{Author}\n";
print "Patch-Author: $headervals{Author}\n";
- print "Subject: $prefix$subject\n\n";
+ my $thisprefix = getprefix($commit_idx);
+ print "Subject: $thisprefix $subject\n\n";
print @headerlines;
$waiting_for_commit = 1;