]> git.droids-corp.org - git-central.git/commitdiff
More email tests.
authorStephen Haberman <stephen@exigencecorp.com>
Tue, 24 Jun 2008 08:26:54 +0000 (03:26 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Tue, 24 Jun 2008 08:26:54 +0000 (03:26 -0500)
server/post-receive-email
tests/t2200-server-post-receive-email.sh
tests/t2201-1.txt [new file with mode: 0644]
tests/t2201-2.txt [new file with mode: 0644]
tests/t2201-3.txt [new file with mode: 0644]
tests/t2201-server-post-receive-email-tags.sh [new file with mode: 0644]
tests/t2202-1.txt [new file with mode: 0644]
tests/t2202-2.txt [new file with mode: 0644]
tests/t2202-server-post-receive-email-branches.sh [new file with mode: 0644]

index 39c32ac43f6f3fd767a82306fca4bde090777569..23b44255e0ba9da3f4c6c1f9cdb67b2643aff53d 100644 (file)
@@ -228,13 +228,13 @@ generate_create_branch_email()
        # ref that were previously not accessible
        # (see generate_update_branch_email for the explanation of this
        # command)
-       git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
-       git rev-list --pretty --reverse --stdin $newrev
+       git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --pretty --reverse --stdin $newrev
        echo $LOGEND
 
        echo ""
        echo "Summary of changes:"
-       git diff-tree --stat -p $newrev
+       oldest_new=$(git rev-parse --not --branches | grep -v $(git rev-parse $refname) | git rev-list --stdin $newrev | tail -n 1)
+       git diff-tree --stat -p $oldest_new^..$newrev
 }
 
 #
index 006bd84747183fc200f7ea5d50f9c48de481cce6..1eda0d81284e0d08cd2fc6fb5d1dad74baa7f53c 100644 (file)
@@ -24,10 +24,10 @@ test_expect_success 'simple commit' '
        echo $test_name >a &&
        git commit -a -m "$test_name" &&
        git push &&
-       old_commit_hash=$(git rev-parse HEAD^)
-       new_commit_hash=$(git rev-parse HEAD)
-       new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD)
-       interpolate ../t2200-1.txt 1.txt old_commit_hash new_commit_hash new_commit_date
+       old_commit_hash=$(git rev-parse HEAD^) &&
+       new_commit_hash=$(git rev-parse HEAD) &&
+       new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
+       interpolate ../t2200-1.txt 1.txt old_commit_hash new_commit_hash new_commit_date &&
        test_cmp 1.txt server/.git/refs.heads.master.out
 '
 
diff --git a/tests/t2201-1.txt b/tests/t2201-1.txt
new file mode 100644 (file)
index 0000000..3a0dbc6
--- /dev/null
@@ -0,0 +1,29 @@
+To: commits@list.com
+Subject: [SCM] UNNAMED PROJECT annotated tag, 1.0, created. 1.0
+X-Git-Refname: refs/tags/1.0
+X-Git-Reftype: annotated tag
+X-Git-Oldrev: 0000000000000000000000000000000000000000
+X-Git-Newrev: $tag_hash
+
+This is an automated email from the git hooks/post-receive script. It was
+generated because a ref change was pushed to the repository containing
+the project "UNNAMED PROJECT".
+
+The annotated tag, 1.0 has been created
+        at  $tag_hash (tag)
+   tagging  $new_commit_hash (commit)
+ tagged by  C O Mitter
+        on  $tag_date
+
+- Log -----------------------------------------------------------------
+1.0
+
+A U Thor (1):
+      setup
+
+-----------------------------------------------------------------------
+
+
+hooks/post-receive
+--
+UNNAMED PROJECT
diff --git a/tests/t2201-2.txt b/tests/t2201-2.txt
new file mode 100644 (file)
index 0000000..2110bc9
--- /dev/null
@@ -0,0 +1,51 @@
+To: commits@list.com
+Subject: [SCM] UNNAMED PROJECT branch, master, updated. 1.0-2-g$new_commit_abbrev
+X-Git-Refname: refs/heads/master
+X-Git-Reftype: branch
+X-Git-Oldrev: $old_commit_hash
+X-Git-Newrev: $new_commit_hash
+
+This is an automated email from the git hooks/post-receive script. It was
+generated because a ref change was pushed to the repository containing
+the project "UNNAMED PROJECT".
+
+The branch, master has been updated
+       via  $new_commit_hash (commit)
+       via  $prior_commit_hash (commit)
+      from  $old_commit_hash (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 $prior_commit_hash
+Author: A U Thor <author@example.com>
+Date:   $prior_commit_date
+
+    commit on tag branch
+
+commit $new_commit_hash
+Author: A U Thor <author@example.com>
+Date:   $new_commit_date
+
+    commit on tag branch 2
+
+-----------------------------------------------------------------------
+
+Summary of changes:
+ a |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/a b/a
+index 146f275..affecee 100644
+--- a/a
++++ b/a
+@@ -1 +1 @@
+-setup
++commit on tag branch 2
+
+
+hooks/post-receive
+--
+UNNAMED PROJECT
diff --git a/tests/t2201-3.txt b/tests/t2201-3.txt
new file mode 100644 (file)
index 0000000..4f3442c
--- /dev/null
@@ -0,0 +1,31 @@
+To: commits@list.com
+Subject: [SCM] UNNAMED PROJECT annotated tag, 2.0, created. 2.0
+X-Git-Refname: refs/tags/2.0
+X-Git-Reftype: annotated tag
+X-Git-Oldrev: 0000000000000000000000000000000000000000
+X-Git-Newrev: $tag_hash
+
+This is an automated email from the git hooks/post-receive script. It was
+generated because a ref change was pushed to the repository containing
+the project "UNNAMED PROJECT".
+
+The annotated tag, 2.0 has been created
+        at  $tag_hash (tag)
+   tagging  $new_commit_hash (commit)
+  replaces  1.0
+ tagged by  C O Mitter
+        on  $tag_date
+
+- Log -----------------------------------------------------------------
+2.0
+
+A U Thor (2):
+      commit on tag branch
+      commit on tag branch 2
+
+-----------------------------------------------------------------------
+
+
+hooks/post-receive
+--
+UNNAMED PROJECT
diff --git a/tests/t2201-server-post-receive-email-tags.sh b/tests/t2201-server-post-receive-email-tags.sh
new file mode 100644 (file)
index 0000000..2a5fb7b
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+test_description='server post-receive email notification'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+       echo "setup" >a &&
+       git add a &&
+       git commit -m "setup" &&
+       git clone ./. server &&
+       rm -fr server/.git/hooks &&
+       git remote add origin ./server &&
+       git config --add branch.master.remote origin &&
+       git config --add branch.master.merge refs/heads/master &&
+       GIT_DIR=./server/.git git config --add hooks.mailinglist commits@list.com &&
+       GIT_DIR=./server/.git git config --add hooks.debug true &&
+       GIT_DIR=.
+'
+
+install_server_hook 'post-receive-email' 'post-receive'
+
+test_expect_success 'create tag' '
+       git tag -a -m 1.0 1.0 &&
+       git push --tags &&
+       new_commit_hash=$(git rev-parse HEAD) &&
+       tag_hash=$(git rev-parse 1.0) &&
+       eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/1.0) &&
+
+       interpolate ../t2201-1.txt 1.txt new_commit_hash tag_hash tag_date &&
+       test_cmp 1.txt server/.git/refs.tags.1.0.out
+'
+
+test_expect_success 'commit on tag branch' '
+       old_commit_hash=$(git rev-parse HEAD) &&
+       echo "$test_name" >a &&
+       git commit -a -m "$test_name" &&
+       prior_commit_hash=$(git rev-parse HEAD) &&
+       prior_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
+
+       echo "$test_name 2" >a &&
+       git commit -a -m "$test_name 2" &&
+       new_commit_hash=$(git rev-parse HEAD) &&
+       new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
+
+       git push &&
+       new_commit_abbrev=$(git rev-list -n 1 --pretty=format:%h HEAD | grep -v commit) &&
+       interpolate ../t2201-2.txt 2.txt old_commit_hash new_commit_hash new_commit_date new_commit_abbrev prior_commit_hash prior_commit_date &&
+       test_cmp 2.txt server/.git/refs.heads.master.out
+'
+
+test_expect_success 'retag branch' '
+       git tag -a -m 2.0 2.0 &&
+       git push --tags &&
+       new_commit_hash=$(git rev-parse HEAD) &&
+       tag_hash=$(git rev-parse 2.0) &&
+       eval $(git for-each-ref --shell "--format=tag_date=%(taggerdate)" refs/tags/2.0) &&
+
+       interpolate ../t2201-3.txt 3.txt new_commit_hash tag_hash tag_date &&
+       test_cmp 3.txt server/.git/refs.tags.2.0.out
+'
+
+test_done
+
diff --git a/tests/t2202-1.txt b/tests/t2202-1.txt
new file mode 100644 (file)
index 0000000..b9c3b3a
--- /dev/null
@@ -0,0 +1,45 @@
+To: commits@list.com
+Subject: [SCM] UNNAMED PROJECT branch, topic, created. $new_commit_hash
+X-Git-Refname: refs/heads/topic
+X-Git-Reftype: branch
+X-Git-Oldrev: 0000000000000000000000000000000000000000
+X-Git-Newrev: $new_commit_hash
+
+This is an automated email from the git hooks/post-receive script. It was
+generated because a ref change was pushed to the repository containing
+the project "UNNAMED PROJECT".
+
+The branch, topic has been created
+        at  $new_commit_hash (commit)
+
+- Log -----------------------------------------------------------------
+commit $prior_commit_hash
+Author: A U Thor <author@example.com>
+Date:   $prior_commit_date
+
+    create branch on topic
+
+commit $new_commit_hash
+Author: A U Thor <author@example.com>
+Date:   $new_commit_date
+
+    create branch on topic 2
+
+-----------------------------------------------------------------------
+
+Summary of changes:
+ a |    2 +-
+ 1 files changed, 1 insertions(+), 1 deletions(-)
+
+diff --git a/a b/a
+index 146f275..8516a40 100644
+--- a/a
++++ b/a
+@@ -1 +1 @@
+-setup
++create branch 2
+
+
+hooks/post-receive
+--
+UNNAMED PROJECT
diff --git a/tests/t2202-2.txt b/tests/t2202-2.txt
new file mode 100644 (file)
index 0000000..3df1b90
--- /dev/null
@@ -0,0 +1,22 @@
+To: commits@list.com
+Subject: [SCM] UNNAMED PROJECT branch, topic, deleted. $old_commit_hash
+X-Git-Refname: refs/heads/topic
+X-Git-Reftype: branch
+X-Git-Oldrev: $old_commit_hash
+X-Git-Newrev: 0000000000000000000000000000000000000000
+
+This is an automated email from the git hooks/post-receive script. It was
+generated because a ref change was pushed to the repository containing
+the project "UNNAMED PROJECT".
+
+The branch, topic has been deleted
+       was  $old_commit_hash
+
+-----------------------------------------------------------------------
+$old_commit_hash create branch on topic 2
+-----------------------------------------------------------------------
+
+
+hooks/post-receive
+--
+UNNAMED PROJECT
diff --git a/tests/t2202-server-post-receive-email-branches.sh b/tests/t2202-server-post-receive-email-branches.sh
new file mode 100644 (file)
index 0000000..da2f7c7
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/sh
+
+test_description='server post-receive email notification'
+
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+       echo "setup" >a &&
+       git add a &&
+       git commit -m "setup" &&
+       git clone ./. server &&
+       rm -fr server/.git/hooks &&
+       git remote add origin ./server &&
+       git config --add branch.master.remote origin &&
+       git config --add branch.master.merge refs/heads/master &&
+       GIT_DIR=./server/.git git config --add hooks.mailinglist commits@list.com &&
+       GIT_DIR=./server/.git git config --add hooks.debug true &&
+       GIT_DIR=.
+'
+
+install_server_hook 'post-receive-email' 'post-receive'
+
+test_expect_success 'create branch' '
+       git checkout -b topic master &&
+       echo "$test_name" >a &&
+       git commit -a -m "$test_name on topic" &&
+       prior_commit_hash=$(git rev-parse HEAD) &&
+       prior_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
+
+       echo "$test_name 2" >a &&
+       git commit -a -m "$test_name on topic 2 " &&
+       new_commit_hash=$(git rev-parse HEAD) &&
+       new_commit_date=$(git log -n 1 --pretty=format:%cd HEAD) &&
+
+       git push origin topic &&
+
+       interpolate ../t2202-1.txt 1.txt new_commit_hash new_commit_date prior_commit_hash prior_commit_date &&
+       test_cmp 1.txt server/.git/refs.heads.topic.out
+'
+
+test_expect_success 'delete branch' '
+       old_commit_hash=$(git rev-parse HEAD) &&
+       git push origin :refs/heads/topic &&
+
+       interpolate ../t2202-2.txt 2.txt old_commit_hash &&
+       test_cmp 2.txt server/.git/refs.heads.topic.out
+'
+
+test_done
+