Created
February 16, 2011 14:50
-
-
Save simonwhitaker/829481 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# A simple shell script for helping you do code reviews on patch files. Feed | |
# in the SHA1 for the commit the patch builds on and the path to the patch | |
# file and it'll spin up a new branch for you, check it out and apply the | |
# patch. You can now use your favourite diff tool to review the patch. | |
usage() { | |
printf "usage: %s <sha> <patchfile>\n" $(basename $0) | |
echo | |
echo "Creates a new branch based at <sha>, checks " | |
echo "it out and applies <patchfile>" | |
} | |
main() { | |
if [ $# -lt 2 ]; then | |
usage | |
exit 1 | |
fi | |
SHA="$1" | |
PATCHFILE="$2" | |
PF_NAME=$(basename $PATCHFILE) | |
BRANCH="cr/${PF_NAME}" | |
echo "Creating branch ${BRANCH} at ${SHA}" | |
git branch $BRANCH $SHA || exit 1 | |
git checkout $BRANCH || exit 1 | |
git apply --whitespace=nowarn $PATCHFILE || exit 1 | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment