summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir@cohens.org.il>2012-06-06 16:26:28 +0300
committerTzafrir Cohen <tzafrir@cohens.org.il>2012-06-06 16:27:31 +0300
commite64ec8674bcb6ba246031a6785c220af8b27bd7b (patch)
treebcd1ae9f92daf08b49d9f5df2a9add99fb0b332e
parent3d8724d0cd5c7821640f57a7f9df64b53a4763a5 (diff)
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 <tzafrir@cohens.org.il>
-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"
+