diff --git a/git-get-repo-and-build.sh b/git-get-repo-and-build.sh index 4eb13ae..32a7114 100755 --- a/git-get-repo-and-build.sh +++ b/git-get-repo-and-build.sh @@ -109,26 +109,33 @@ fi # See if repo exits in git if [ $DEBUG ] ; then echo "check if $REPO_NAME in $ORG_NAME exists on $GITEAHOST" ; fi -RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME") +BRANCHES= +if [ $BRANCH ] ; then $BRANCHES="/branches/${BRANCH#*=}" ; file +RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME$BRANCHES") if [ "$RESPONSE" == "200" ]; then - if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME exists!" ; fi + if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME exists!" ; fi else - if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME does not exist" ; fi - while true; do - read -p "Do you wish to run git-cvs2git?(y/n) " yn - case $yn in - [Yy]* ) - if [ $DEBUG ] ; then echo "running git-cvs2git.sh" ; fi - logname="git-cvs2git-create-$ORG_NAME-$REPO_NAME-$(date +'%FT%H%M').log" - git-cvs2git.sh "$REPO_NAME" "$ORG_NAME" > $logname - break;; - [Nn]* ) exit;; - * ) echo "Please answer yes or no.";; - esac - done + if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME does not exist" ; fi + if [ $BRANCH ] ; then + echo "Can't find the ${BRANCH#*=} branch of $ORG_NAME/$REPO_NAME - exiting" + exit 1 + else + while true; do + read -p "Do you wish to run git-cvs2git?(y/n) " yn + case $yn in + [Yy]* ) + if [ $DEBUG ] ; then echo "running git-cvs2git.sh" ; fi + logname="git-cvs2git-create-$ORG_NAME-$REPO_NAME-$(date +'%FT%H%M').log" + git-cvs2git.sh "$REPO_NAME" "$ORG_NAME" > $logname + break;; + [Nn]* ) exit;; + * ) echo "Please answer yes or no.";; + esac + done + fi # And check it is now there - if [ $DEBUG ] ; then echo "check if $REPO_NAME in $ORG_NAME exists on $GITEAHOST" ; fi - RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME") + if [ $DEBUG ] ; then echo "check if $REPO_NAME in $ORG_NAME exists on $GITEAHOST" ; fi + RESPONSE=$(curl $SILENT -o /dev/null -w "%{http_code}" "$GITEAHOST/api/v1/repos/$ORG_NAME/$REPO_NAME$BRANCHES") if [ "$RESPONSE" == "200" ]; then if [ $DEBUG ] ; then echo "Repository for $ORG_NAME/$REPO_NAME created sucessfully!" ; fi else