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 # ignore all commits already present in these refs
14 # EXCLUDE="refs/heads/upstream refs/heads/other-project"
18 PWDIR=/srv/patchwork/apps/patchwork
26 hash=$(git show $1 | python $PWDIR/parser.py --hash)
34 id=$($PWDIR/bin/pwclient info -h $1 2>/dev/null \
35 | sed -rne 's,- id[[:space:]]*: ,,p')
42 $PWDIR/bin/pwclient update -s $2 -c $3 $1 2>&1
48 for rev in $(git rev-parse --not ${EXCLUDE} |
49 git rev-list --stdin --no-merges --reverse ${1}..${2}); do
50 if [ "$do_exit" = 1 ]; then
51 echo "I: exiting..." >&2
54 hash=$(get_patchwork_hash $rev) \
55 || { echo "E: failed to hash rev $rev." >&2; continue; }
56 id=$(get_patch_id $hash) \
57 || { echo "E: failed to find patch for rev $rev." >&2; continue; }
58 reason="$(set_patch_state $id $3 $rev)" \
59 || { echo "E: failed to update patch #$id${reason:+: $reason}." >&2; continue; }
60 echo "I: patch #$id updated using rev $rev." >&2
63 echo "I: $cnt patch(es) updated to state $3." >&2
66 while read oldrev newrev refname; do
68 for i in $STATE_MAP; do
70 if [ "$key" = "$refname" ]; then
71 update_patches $oldrev $newrev ${i#*:}
76 if [ $found -eq 0 ]; then
77 echo "E: STATE_MAP has no mapping for branch $refname" >&2