I just finished a version of my git-request-review script.

For those who are not yet using it it's meant to make sending patches to gerrit more streamlined. It show you a list of the patches before sending them and also warns you if you are not rebased.

To have it working you need to have a configured remote for gerrit already in your git config In order for git to detect it as a new verb you have to have this in your path

usage: git request-review <gerrit-remote> <remote-branch>

eg. git request-review gerrit master

For those of you who are using the old version will probably notice this version forgoes special gerrit configuration and can support multiple gerrit servers (just configure more remotes).

Fixes, features and comments are always welcome.

Happy reviewing.


#!/bin/bash
#
# Copyright 2011 Saggi Mizrahi <smizr...@redhat.com>
#
# 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 <gerrit-remote> <remote-branch>"
        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
_______________________________________________
vdsm-devel mailing list
vdsm-devel@lists.fedorahosted.org
https://fedorahosted.org/mailman/listinfo/vdsm-devel

Reply via email to