From: Hugo Villeneuve Date: Tue, 16 Jan 2018 19:58:22 +0000 (-0500) Subject: Simplify output of git-project-update.sh X-Git-Url: http://gitweb.hugovil.com/?p=hvutilities.git;a=commitdiff_plain;h=d625d5724374aa20dd8752d007e29a92acd8c434 Simplify output of git-project-update.sh --- diff --git a/scripts/git-project-update.sh b/scripts/git-project-update.sh index 6fec40b..0a37cc1 100755 --- a/scripts/git-project-update.sh +++ b/scripts/git-project-update.sh @@ -35,6 +35,8 @@ branch=${1} update_repo() { + local valid="0" + if [ ${#} -ne 1 ]; then echo "Missing repository name" exit 1 @@ -42,35 +44,25 @@ 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 - fi + vco -q ${b} 1> /dev/null + echo "${b}" + valid="1" + break fi + done + + if [ x"${valid}" = x"0" ]; then + echo "No valid branch found" fi + popd 1> /dev/null }