#!/bin/bash
#gitdir=$(git rev-parse --git-dir); scp -p -P 29418 jeflin02@szc-gerrit.armchina.com:hooks/commit-msg ${gitdir}/hooks/
DIR=`pwd`
if [ ! -f "$DIR/.git/config" ];
then
echo "No .git folder!"
exit
fi
if [ $1 != "" ];
then
BRANCH_NMAE=$1
else
BRANCH_NMAE=`git symbolic-ref --short -q HEAD`
fi
echo "branch name: $BRANCH_NMAE"
GERRIT_PATH=`cat $DIR/.git/config | grep url | head -n 1 | awk '{print $3}'`
echo $GERRIT_PATH
echo "Push!"
git push ${GERRIT_PATH} HEAD:refs/for/$BRANCH_NMAE
echo "Finish!"