#!/bin/bash # # Copyright 2011 Saggi Mizrahi # # Licensed to you under the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. See the files README and # LICENSE_GPL_v2 which accompany this distribution. # if [ -z $2 ]; then echo "usage: git request-review " exit 1 fi git remote show $1 &> /dev/null if [ $? -ne 0 ]; then echo "Remote '$1' is not configured" exit 1 fi FETCH_REMOTE=`git remote show $1 | grep Fetch | awk {'print $3'}` PUSH_REMOTE=`git remote show $1 | grep Push | awk {'print $3'}` git fetch $FETCH_REMOTE refs/heads/$2 &> /dev/null if [ $? -ne 0 ]; then echo "Problem fetching current head, please try manually" exit 1 fi echo "Analyzing diff with upstream..." TAGS=`git log --format="%d" $1/$2~..FETCH_HEAD` if [ -z "$TAGS" ]; then echo "Remote HEAD doesn't seem to be a local branch, you are probably not rebased" while true; do read -p "Do you want to push patches anyway?" yn case $yn in [Yy]* ) break;; [Nn]* ) exit;; * ) echo "Please answer yes or no.";; esac done fi git --no-pager log --oneline --decorate FETCH_HEAD..HEAD if [ $? -ne 0 ]; then echo "Branch is not rebased" exit 1 fi while true; do read -p "Do you wish to send these patches for review?" yn case $yn in [Yy]* ) break;; [Nn]* ) exit;; * ) echo "Please answer yes or no.";; esac done echo "Sending patches for review..." git push --force $PUSH_REMOTE HEAD:refs/for/$2