From 9820df3feea01cfe346dcc8483a579a1916f5667 Mon Sep 17 00:00:00 2001 From: Stephen Haberman Date: Sat, 23 Aug 2008 00:45:33 -0500 Subject: [PATCH] Try passing in git describe too. --- server/post-receive-trac | 5 ++++- server/post-receive-trac.py | 5 +++-- tests/t3000-server-post-receive-trac.sh | 23 ++++++++++++++++++----- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/server/post-receive-trac b/server/post-receive-trac index a4c08d3..21ac0f4 100644 --- a/server/post-receive-trac +++ b/server/post-receive-trac @@ -17,8 +17,11 @@ while read oldrev newrev refname ; do esac set_new_commits + set_rev_types + set_describe + echo "$new_commits" | git rev-list --reverse --stdin | while read commit ; do - "$PYTHON" "$POST_RECEIVE_TRAC" "$TRAC_ENV" "$short_refname" "$commit" + "$PYTHON" "$POST_RECEIVE_TRAC" "$TRAC_ENV" "$short_refname" "$describe" "$commit" done done diff --git a/server/post-receive-trac.py b/server/post-receive-trac.py index 2814eff..768b308 100644 --- a/server/post-receive-trac.py +++ b/server/post-receive-trac.py @@ -18,7 +18,8 @@ from trac.versioncontrol.api import NoSuchChangeset project = sys.argv[1] refname = sys.argv[2] -rev = sys.argv[3] +describe = sys.argv[3] +rev = sys.argv[4] def refs(ticket): pass @@ -64,7 +65,7 @@ for ticketId, commands in tickets.iteritems(): username = authorPattern.findall(changeset.author)[0] now = datetime.now(utc) - message = "(On %s [%s]) %s" % (refname, rev, changeset.message) + message = "(On %s [../changeset/%s %s]) %s" % (refname, rev, describe, 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 46881c8..8468b57 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 topic1 $new_commit_hash" + cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic1 $new_commit_hash $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 topic2 $existing_commit_hash" + ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2 $existing_commit_hash $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 topic2 $new_commit_hash" + cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2 $new_commit_hash $new_commit_hash" ' test_expect_success 'update branch to an already published commit does not double tap' ' @@ -55,8 +55,21 @@ 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 $topic2_hash" - ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic1 $topic1_hash" + ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic2 $topic2_hash $topic2_hash" + ! cat push.err | grep "/foo/post-receive-trac.py /foo/trac topic1 $topic1_hash $topic1_hash" +' + +test_expect_success 'update branch with abbreviation' ' + git checkout topic2 + git tag -m "release1" release1 && + git push --tags && + + echo "$test_name" >a && + git commit -a -m "changed on topic2" && + new_commit_describe=$(git describe HEAD) && + 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 topic2 $new_commit_describe $new_commit_hash" ' test_done -- 2.39.5