From b006b5b2ce404b9dbd30b0c608a1aee5998437ae Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Fri, 22 Aug 2008 21:58:55 -0500 Subject: [PATCH] Include the refname in the trac comment. --- server/post-receive-trac | 15 ++++++++++++++- server/post-receive-trac.py | 6 ++++-- tests/t3000-server-post-receive-trac.sh | 10 +++++----- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/server/post-receive-trac b/server/post-receive-trac index 828da27..a4c08d3 100644 --- a/server/post-receive-trac +++ b/server/post-receive-trac @@ -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 diff --git a/server/post-receive-trac.py b/server/post-receive-trac.py index 661cb37..2814eff 100644 --- a/server/post-receive-trac.py +++ b/server/post-receive-trac.py @@ -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() diff --git a/tests/t3000-server-post-receive-trac.sh b/tests/t3000-server-post-receive-trac.sh index 38e4262..46881c8 100644 --- a/tests/t3000-server-post-receive-trac.sh +++ b/tests/t3000-server-post-receive-trac.sh @@ -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 -- 2.39.5