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 GNU General Public License v2 or later.
9 #TODO: the state map should really live in the repo's git-config
10 STATE_MAP="refs/heads/master:Accepted"
12 PWDIR=/srv/patchwork/apps/patchwork
20 hash=$(git show $1 | python $PWDIR/parser.py --hash)
28 id=$($PWDIR/bin/pwclient view -h $1 2>/dev/null \
29 | sed -rne 's,X-Patchwork-Id: ,,p')
36 $PWDIR/bin/pwclient update -s $2 -c $3 $1 2>&1
42 for rev in $(git rev-list --no-merges --reverse ${1}^..${2}); do
43 if [ "$do_exit" = 1 ]; then
44 echo "I: exiting..." >&2
47 hash=$(get_patchwork_hash $rev) \
48 || { echo "E: failed to hash rev $rev." >&2; continue; }
49 id=$(get_patch_id $hash) \
50 || { echo "E: failed to find patch for rev $rev." >&2; continue; }
51 reason="$(set_patch_state $id $3 $rev)" \
52 || { echo "E: failed to update patch #$id${reason:+: $reason}." >&2; continue; }
53 echo "I: patch #$id updated using rev $rev." >&2
56 echo "I: $cnt patch(es) updated to state $3." >&2
59 while read oldrev newrev refname; do
61 for i in $STATE_MAP; do
63 if [ "$key" = "$refname" ]; then
64 update_patches $oldrev $newrev ${i#*:}
69 if [ $found -eq 0 ]; then
70 echo "E: no mapping for refname $key" >&2