. $(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
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
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()
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' '
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' '
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