This replaces the older 'parser' main function. Signed-off-by: Stephen Finucane <step...@that.guru> Cc: Paul Jakma <p...@jakma.org> --- tools/patchwork-update-commits | 18 ++++++++++++++---- tools/post-receive.hook | 21 +++++++++++++++------ 2 files changed, 29 insertions(+), 10 deletions(-)
diff --git a/tools/patchwork-update-commits b/tools/patchwork-update-commits index d0f63a9..c5e8b15 100755 --- a/tools/patchwork-update-commits +++ b/tools/patchwork-update-commits @@ -19,8 +19,16 @@ # along with Patchwork; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -toolsdir="$(dirname "$0")" -pwpath="${toolsdir}"/../patchwork +BASE_DIR=`dirname $0` +PW_DIR=`readlink -e $BASE_DIR/..` + +if [ -z $PW_PYTHON ]; then + PW_PYTHON=python2 +fi + +if [ -z $DJANGO_SETTINGS_MODULE ]; then + DJANGO_SETTINGS_MODULE=patchwork.settings.production +fi if [ "$#" -lt 1 ]; then echo "usage: $0 <revspec>" >&2 @@ -29,6 +37,8 @@ fi git rev-list --reverse "$@" | while read commit; do - hash=$(git show "$commit" | python $pwpath/parser.py -#) - $pwpath/bin/pwclient update -s Accepted -c "$commit" -h "$hash" + hash=$(git show "$commit" | \ + DJANGO_SETTINGS_MODULE="$DJANGO_SETTINGS_MODULE" \ + $PW_PYTHON "$PW_DIR/manage.py" parsemail --hash --verbosity=0) + $PW_DIR/patchwork/bin/pwclient update -s Accepted -c "$commit" -h "$hash" done diff --git a/tools/post-receive.hook b/tools/post-receive.hook index a19e1b2..aba7b8a 100755 --- a/tools/post-receive.hook +++ b/tools/post-receive.hook @@ -30,29 +30,38 @@ STATE_MAP="refs/heads/master:Accepted" # EXCLUDE="" -PWDIR=/opt/patchwork/patchwork +PW_DIR=/opt/patchwork do_exit=0 trap "do_exit=1" INT -get_patchwork_hash() -{ +if [ -z $PW_PYTHON ]; then + PW_PYTHON=python2 +fi + +if [ -z $DJANGO_SETTINGS_MODULE ]; then + DJANGO_SETTINGS_MODULE=patchwork.settings.production +fi + +get_patchwork_hash() { local hash - hash=$(git show -C $1 | python $PWDIR/parser.py --hash) + hash=$(git show -C $1 | \ + DJANGO_SETTINGS_MODULE="$DJANGO_SETTINGS_MODULE" \ + $PW_PYTHON "$PW_DIR/manage.py" parsemail --hash --verbosity 0) echo $hash test -n "$hash" } get_patch_id() { local id - id=$($PWDIR/bin/pwclient info -h $1 2>/dev/null \ + id=$($PW_DIR/patchwork/bin/pwclient info -h $1 2>/dev/null \ | sed -rne 's,- id[[:space:]]*: ,,p') echo $id test -n "$id" } set_patch_state() { - $PWDIR/bin/pwclient update -s $2 -c $3 $1 2>&1 + $PW_DIR/patchwork/bin/pwclient update -s $2 -c $3 $1 2>&1 } update_patches() { -- 2.7.4 _______________________________________________ Patchwork mailing list Patchwork@lists.ozlabs.org https://lists.ozlabs.org/listinfo/patchwork