#!/bin/sh # git-post-review: post a review to the ReviewBoard based on a local git # diff. The SVN information is based on the 'git-svn-id' data from # the git HEAD. # Based on 'git-svn-diff by Leif Hedstrom from: # http://www.mail-archive.com/dev@trafficserver.apache.org/msg00864.html set -e svn_url=`git show HEAD | awk '/git-svn-id:/ {print $2}' | head -n1` line='===================================================================' REV=`echo $svn_url | cut -d'@' -f2 | cut -d' ' -f1` BRANCH=`echo $svn_url | sed -e 's|@.*||' -e 's|.*/svn/[^/]*/|/|'` tempfile=`mktemp post-review-XXXXXX` #git diff --no-prefix $(git rev-list --date-order --max-count=1 $TRACKING_BRANCH) $* | git diff --no-prefix | sed -e "s|^\(+++ \)\(.*\)|\1$BRANCH/\2 (working copy)|" \ -e "s|^\(--- \)\(.*\)|\1$BRANCH/\2 (revision $REV)|" \ -e "s/^diff --git [^[:space:]]*/Index:/" \ -e "s/^index.*/$line/" \ > "$tempfile" REPO_URL=`echo $svn_url | cut -d/ -f1-5` post-review --branch="$BRANCH" --repository-url=$REPO_URL --diff-filename="$tempfile" "$@" rm "$tempfile"