From e64ec8674bcb6ba246031a6785c220af8b27bd7b Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Wed, 6 Jun 2012 16:26:28 +0300 Subject: git-post-review: post a review to the ReviewBoard 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 Signed-off-by: Tzafrir Cohen --- git-post-review | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 git-post-review diff --git a/git-post-review b/git-post-review new file mode 100755 index 0000000..1bf9077 --- /dev/null +++ b/git-post-review @@ -0,0 +1,31 @@ +#!/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 --repository-url=$REPO_URL --diff-filename="$tempfile" "$@" + +rm "$tempfile" + -- cgit v1.2.3