Created
April 22, 2014 22:36
-
-
Save toddlipcon/11196745 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
REMOTE=${GERRIT:-gerrit} | |
GERRIT_NUMBER=$1 | |
REV_A=$2 | |
REV_B=$3 | |
if ! [[ "$GERRIT_NUMBER" =~ "[0-9]+" ]] || \ | |
! [[ "$REV_A" =~ "[0-9]+" ]] || \ | |
! [[ "$REV_B" =~ "[0-9]+" ]] ; then | |
echo "usage: $0 <gerrit number> <rev 1> <rev 2>" | |
echo | |
echo eg: $0 12345 1 3 | |
echo will show the diff between revision 1 and 3 of gerrit #12345 | |
fi | |
last_two_digits=$(echo $GERRIT_NUMBER | tail --bytes=3) | |
set -e | |
git fetch $REMOTE refs/changes/$last_two_digits/$GERRIT_NUMBER/$REV_A | |
git format-patch -1 --stdout FETCH_HEAD > /tmp/$GERRIT_NUMBER.$REV_A.patch | |
git fetch $REMOTE refs/changes/$last_two_digits/$GERRIT_NUMBER/$REV_B | |
git format-patch -1 --stdout FETCH_HEAD > /tmp/$GERRIT_NUMBER.$REV_B.patch | |
diff /tmp/$GERRIT_NUMBER.{$REV_A,$REV_B}.patch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment