From 9c43e655de835ebf706f8845f56f7f45be0f2ad5 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Tue, 11 Nov 2008 22:43:50 -0600 Subject: [PATCH] Use tags in the email subject to pick up commit numbers. --- server/post-receive-email | 4 ++-- tests/t2200-2.txt | 38 +++++++++++++++++++++++++++++++ tests/t2200-post-receive-email.sh | 17 ++++++++++++++ tests/t2201-4.txt | 2 +- tests/t2201-5.txt | 2 +- 5 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 tests/t2200-2.txt diff --git a/server/post-receive-email b/server/post-receive-email index 629fb6c..8d5d5c8 100755 --- a/server/post-receive-email +++ b/server/post-receive-email @@ -63,7 +63,7 @@ generate_email() set_change_type set_rev_types - set_describe + set_describe_tags # The revision type tells us what type the commit is, combined with # the location of the ref we can decide between @@ -136,7 +136,7 @@ generate_email_header() cat <<-EOF From: $USER_EMAIL To: $recipients - Subject: ${emailprefix} $short_refname $refname_type ${change_type}d. $describe + Subject: ${emailprefix} $short_refname $refname_type ${change_type}d. $describe_tags X-Git-Refname: $refname X-Git-Reftype: $refname_type X-Git-Oldrev: $oldrev diff --git a/tests/t2200-2.txt b/tests/t2200-2.txt new file mode 100644 index 0000000..2312907 --- /dev/null +++ b/tests/t2200-2.txt @@ -0,0 +1,38 @@ +From: author@example.com +To: commits@list.com +Subject: [cbas] master branch updated. r/1000 +X-Git-Refname: refs/heads/master +X-Git-Reftype: branch +X-Git-Oldrev: $old_commit_hash +X-Git-Newrev: $new_commit_hash + +The branch, master has been updated + via $new_commit_abbrev simple commit with commitnumber + from $old_commit_abbrev simple commit + +Those revisions listed above that are new to this repository have +not appeared on any other notification email; so we list those +revisions in full, below. + +- Log ----------------------------------------------------------------- + +commit $new_commit_hash +Author: A U Thor +Date: $new_commit_date + + simple commit with commitnumber + +$new_commit_hash +diff --git a/a b/a +index b38f23c..bd6aaf6 100644 +--- a/a ++++ b/a +@@ -1 +1 @@ +-simple commit ++simple commit with commitnumber + +----------------------------------------------------------------------- + +Summary of changes: + a | 2 +- + 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/tests/t2200-post-receive-email.sh b/tests/t2200-post-receive-email.sh index 28733db..45d3e4f 100644 --- a/tests/t2200-post-receive-email.sh +++ b/tests/t2200-post-receive-email.sh @@ -37,5 +37,22 @@ test_expect_success 'simple commit' ' test_cmp 1.txt server/.git/refs.heads.master.out ' +test_expect_success 'simple commit with commitnumber' ' + old_commit_hash=$(git rev-parse HEAD) && + old_commit_abbrev=$(git rev-parse --short HEAD) && + + echo $test_name >a && + git commit -a -m "$test_name" && + git tag r/1000 && + git push --tags && + git push && + new_commit_hash=$(git rev-parse HEAD) && + new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) && + new_commit_abbrev=$(git rev-parse --short HEAD) && + + interpolate ../t2200-2.txt 2.txt old_commit_hash old_commit_abbrev new_commit_hash new_commit_date new_commit_abbrev && + test_cmp 2.txt server/.git/refs.heads.master.out +' + test_done diff --git a/tests/t2201-4.txt b/tests/t2201-4.txt index 47bd8c3..cfec50e 100644 --- a/tests/t2201-4.txt +++ b/tests/t2201-4.txt @@ -1,6 +1,6 @@ From: author@example.com To: commits@list.com -Subject: [cbas] 2.1 tag created. $new_commit_describe +Subject: [cbas] 2.1 tag created. 2.1 X-Git-Refname: refs/tags/2.1 X-Git-Reftype: tag X-Git-Oldrev: 0000000000000000000000000000000000000000 diff --git a/tests/t2201-5.txt b/tests/t2201-5.txt index 8fbafe6..f32e24a 100644 --- a/tests/t2201-5.txt +++ b/tests/t2201-5.txt @@ -1,6 +1,6 @@ From: author@example.com To: commits@list.com -Subject: [cbas] 2.1 tag updated. $new_commit_describe +Subject: [cbas] 2.1 tag updated. 2.1 X-Git-Refname: refs/tags/2.1 X-Git-Reftype: tag X-Git-Oldrev: $old_commit_hash -- 2.39.5