3 # Git post-receive hook to update Patchwork patches after Git pushes
5 # Copyright © 2010 martin f. krafft <madduck@madduck.net>
6 # Released under the terms of the Artistic Licence 2.0
10 #TODO: the state map should really live in the repo's git-config
11 STATE_MAP="refs/heads/master:Accepted"
13 PWDIR=/srv/patchwork/apps/patchwork
21 hash=$(git show $1 | python $PWDIR/parser.py --hash)
29 id=$($PWDIR/bin/pwclient view -h $1 2>/dev/null \
30 | sed -rne 's,X-Patchwork-Id: ,,p')
37 $PWDIR/bin/pwclient update -s $2 -c $3 $1 2>&1
43 for rev in $(git rev-list --no-merges --reverse ${1}^..${2}); do
44 if [ "$do_exit" = 1 ]; then
45 echo "I: exiting..." >&2
48 hash=$(get_patchwork_hash $rev) \
49 || { echo "E: failed to hash rev $rev." >&2; continue; }
50 id=$(get_patch_id $hash) \
51 || { echo "E: failed to find patch for rev $rev." >&2; continue; }
52 reason="$(set_patch_state $id $3 $rev)" \
53 || { echo "E: failed to update patch #$id${reason:+: $reason}." >&2; continue; }
54 echo "I: patch #$id updated using rev $rev." >&2
57 echo "I: $cnt patch(es) updated to state $3." >&2
60 while read oldrev newrev refname; do
62 for i in $STATE_MAP; do
64 if [ "$key" = "$refname" ]; then
65 update_patches $oldrev $newrev ${i#*:}
70 if [ $found -eq 0 ]; then
71 echo "E: no mapping for refname $key" >&2