]> git.droids-corp.org - git-central.git/commitdiff
Include the refname in the trac comment.
authorStephen Haberman <stephen@exigencecorp.com>
Sat, 23 Aug 2008 02:58:55 +0000 (21:58 -0500)
committerStephen Haberman <stephen@exigencecorp.com>
Sat, 23 Aug 2008 02:58:55 +0000 (21:58 -0500)
server/post-receive-trac
server/post-receive-trac.py
tests/t3000-server-post-receive-trac.sh

index 828da272fdc3393b722dcf74c706b93132883faa..a4c08d3e321b9f21bc4505e248c54c14b55ebc09 100644 (file)
@@ -3,9 +3,22 @@
 . $(dirname $0)/functions
 
 while read oldrev newrev refname ; do
+       case "$refname" in
+               refs/tags/*)
+                       short_refname=${refname##refs/tags/}
+                       ;;
+               refs/heads/*)
+                       short_refname=${refname##refs/heads/}
+                       ;;
+               *)
+                       echo >&2 "*** Unknown type of update to $refname"
+                       exit 1
+                       ;;
+       esac
+
        set_new_commits
        echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do
-               "$PYTHON" "$POST_RECEIVE_TRAC" "$TRAC_ENV" "$commit"
+               "$PYTHON" "$POST_RECEIVE_TRAC" "$TRAC_ENV" "$short_refname" "$commit"
        done
 done
 
index 661cb379873f37b6812145fb8de19c337f572f81..2814effeeb21d8c904138826897383afb6313f4e 100644 (file)
@@ -17,7 +17,8 @@ from trac.util.datefmt import utc
 from trac.versioncontrol.api import NoSuchChangeset
 
 project = sys.argv[1]
-rev = sys.argv[2]
+refname = sys.argv[2]
+rev = sys.argv[3]
 
 def refs(ticket):
        pass
@@ -63,7 +64,8 @@ for ticketId, commands in tickets.iteritems():
 
        username = authorPattern.findall(changeset.author)[0]
        now = datetime.now(utc)
-       message = "(In [%s]) %s" % (rev, changeset.message)
+       message = "(On %s [%s]) %s" % (refname, rev, changeset.message)
+       ticket['branch'] = refname
        ticket.save_changes(username, message, now, db, cnum+1)
        db.commit()
 
index 38e4262125e88d419218ef3ed4e6091fb7a0876f..46881c8b60e0a2a4ab34a57b694c155180a9213d 100644 (file)
@@ -25,14 +25,14 @@ test_expect_success 'new branch' '
        git commit -a -m "changed on topic1" &&
        new_commit_hash=$(git rev-parse HEAD) &&
        git push origin topic1 2>push.err &&
-       cat push.err | grep "/foo/post-receive-trac.py /foo/trac $new_commit_hash"
+       cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic1 $new_commit_hash"
 '
 
 test_expect_success 'new branch with already existing does not double tap' '
        git checkout -b topic2 topic1 &&
        existing_commit_hash=$(git rev-parse HEAD) &&
        git push origin topic2 2>push.err &&
-       ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac $existing_commit_hash"
+       ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2 $existing_commit_hash"
 '
 
 test_expect_success 'update branch' '
@@ -41,7 +41,7 @@ test_expect_success 'update branch' '
        git commit -a -m "changed on topic2" &&
        new_commit_hash=$(git rev-parse HEAD) &&
        git push origin topic2 2>push.err &&
-       cat push.err | grep "/foo/post-receive-trac.py /foo/trac $new_commit_hash"
+       cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2 $new_commit_hash"
 '
 
 test_expect_success 'update branch to an already published commit does not double tap' '
@@ -55,8 +55,8 @@ test_expect_success 'update branch to an already published commit does not doubl
 
        git push 2>push.err &&
 
-       ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac $topic2_hash"
-       ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac $topic1_hash"
+       ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2 $topic2_hash"
+       ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic1 $topic1_hash"
 '
 
 test_done