X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=scripts%2Fgit-project-update.sh;h=302a4f8a2d3c70c65b2289521160d72876a93523;hb=cbde02b39d3ec7a809f529ec9e83afaaad0f84fd;hp=6fec40b262cdbc0ac3e837fe53c29e7fcb9917bc;hpb=d240fda92b8bd822645ebeca8831d204746376da;p=hvutilities.git diff --git a/scripts/git-project-update.sh b/scripts/git-project-update.sh index 6fec40b..302a4f8 100755 --- a/scripts/git-project-update.sh +++ b/scripts/git-project-update.sh @@ -32,9 +32,12 @@ if [ ! -f ${SUBREPOS_LIST} ]; then fi branch=${1} +rc=0 update_repo() { + local valid="0" + if [ ${#} -ne 1 ]; then echo "Missing repository name" exit 1 @@ -42,35 +45,30 @@ update_repo() local r=${1} - echo "Repo ${r}:" + echo -n "Repo ${r}: " pushd "${r}" 1> /dev/null b=${branch} - exists=$(git show-ref refs/heads/${b}) - - if [ -n "$exists" ]; then - [ -n "${debug}" ] && echo "branch <${b}> exists" - vco ${b} 1> /dev/null - else - echo "Branch <${b}> not found, trying " - b=latest + + for b in ${branch} latest master; do exists=$(git show-ref refs/heads/${b}) if [ -n "$exists" ]; then - [ -n "${debug}" ] && echo "branch <${b}> exists" - vco ${b} 1> /dev/null - else - echo "Branch <${b}> not found, defaulting to " - b=master - exists=$(git show-ref refs/heads/${b}) - if [ -n "$exists" ]; then - [ -n "${debug}" ] && echo "branch <${b}> exists" - vco ${b} 1> /dev/null - else - echo "Error swtiching to branch <${b}>" - exit 1 + vco -q ${b} 1> /dev/null + + if [ ${?} -ne 0 ]; then + rc=1 fi + echo "${b}" + valid="1" + break fi + done + + if [ x"${valid}" = x"0" ]; then + echo "No valid branch found" + rc=1 fi + popd 1> /dev/null } @@ -95,3 +93,5 @@ while IFS=$'\n' read r ; do update_repo ${r} done < ${SUBREPOS_LIST} + +exit ${rc}