git-review (740B)
1 #!/usr/bin/env bash 2 3 set -e 4 5 REMOTE="$1" 6 BRANCH="$2" 7 BASE=${BASE_BRANCH:-${3:-master}} 8 DIR="patches/${4:-$BRANCH}" 9 10 usage() { 11 printf "git-review <remote> <branch> [remote-base-branch (def: master)] [patch-dir-name]\n" 12 exit 1 13 } 14 15 start_review() { 16 diffs "$DIR"/*.patch 17 } 18 19 if [ -z "$2" ]; then 20 usage 21 fi 22 23 if [ -d "$DIR" ]; then 24 read -p "Found $DIR, review this? (y/n): " res 25 if [ "$res" == "" ] || [ "$res" == "y" ]; then 26 start_review 27 exit 0 28 fi 29 fi 30 31 git fetch origin $BASE 32 git fetch "$REMOTE" "$BRANCH" 33 34 rm -rf "$DIR" 35 mkdir -p "$DIR" 36 37 printf "git format-patch origin/%s..FETCH_HEAD -o %s\n" "$BASE" "$DIR" 38 git format-patch -U8 origin/$BASE..FETCH_HEAD -o "$DIR" 39 40 printf "$DIR\n" 41 42 read -p "Press enter to review." 43 44 start_review