Commit b6dc5a0e authored by Robert Ricci's avatar Robert Ricci

Show commit range on updates

Show the old and new values of the ref, in a form that is suitable for
passing to 'git log', etc. The idea is to make it easier for the reader
of the mail to go look at more detailed information than is in the mail,
if they so choose.

Use short form of the hashes to make it fit nicely into one line
of text.
parent 3b96945a
...@@ -253,13 +253,14 @@ sub change_type($$$); ...@@ -253,13 +253,14 @@ sub change_type($$$);
sub ref_type($); sub ref_type($);
sub rev_type($); sub rev_type($);
sub revparse($); sub revparse($);
sub short_hash($);
sub changed_files(@); sub changed_files(@);
sub get_mail_addresses($@); sub get_mail_addresses($@);
sub get_merge_base($$); sub get_merge_base($$);
sub get_summary($); sub get_summary($);
sub uniq(@); sub uniq(@);
sub flatten_arrayref($); sub flatten_arrayref($);
sub commit_mail($\@$@); sub commit_mail($$$\@$@);
sub get_commits($$$); sub get_commits($$$);
sub send_mail($$$@); sub send_mail($$$@);
sub short_refname($); sub short_refname($);
...@@ -459,7 +460,7 @@ foreach my $refline (@reflines) { ...@@ -459,7 +460,7 @@ foreach my $refline (@reflines) {
# Send off the mail! # Send off the mail!
# #
if (@mailaddrs) { if (@mailaddrs) {
commit_mail($ct,@commits,$refname,@mailaddrs); commit_mail($ct,$oldrev,$newrev,@commits,$refname,@mailaddrs);
} }
} }
...@@ -540,6 +541,16 @@ sub revparse($) { ...@@ -540,6 +541,16 @@ sub revparse($) {
return $parsedrev; return $parsedrev;
} }
#
# Take a git hash and return the short (abbreviated) form.
#
sub short_hash($) {
my ($hash) = @_;
my $short = `$GIT rev-parse --short $hash $STDERRNULL`;
chomp($short);
return $short;
}
# #
# Given a list of commit object hashes, return the list of files changed by # Given a list of commit object hashes, return the list of files changed by
# all commits. # all commits.
...@@ -716,7 +727,7 @@ sub flatten_arrayref($) { ...@@ -716,7 +727,7 @@ sub flatten_arrayref($) {
# Send mail about a regular update commit # Send mail about a regular update commit
# #
sub commit_mail($\@$@) { sub commit_mail($\@$@) {
my ($ct,$commits,$refname,@mailaddrs) = @_; my ($ct,$oldrev,$newrev,$commits,$refname,@mailaddrs) = @_;
# #
# Construct the subject line. For now, we just say what repo (if defined) # Construct the subject line. For now, we just say what repo (if defined)
...@@ -760,6 +771,10 @@ sub commit_mail($\@$@) { ...@@ -760,6 +771,10 @@ sub commit_mail($\@$@) {
$actionstring .= " to point to the following commit:"; $actionstring .= " to point to the following commit:";
} elsif ($ct eq $CT_DELETE) { } elsif ($ct eq $CT_DELETE) {
$actionstring .= ". It previously pointed to the following commit:"; $actionstring .= ". It previously pointed to the following commit:";
} elsif ($ct eq $CT_UPDATE) {
my $oldshort = short_hash($oldrev);
my $newshort = short_hash($newrev);
$actionstring .= ": $oldshort..$newshort";
} }
$actionstring .= "\n\n"; $actionstring .= "\n\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment