summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-post-review31
1 files changed, 31 insertions, 0 deletions
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"
+