X-Git-Url: http://gitweb.hugovil.com/?a=blobdiff_plain;f=scripts%2Fgit-project-update.sh;h=6b6895f0c9befa906872439d6a6a2dd477acf5a0;hb=8c14aea36db58f7eb1a7ee34f4c9dd440831f1df;hp=6fec40b262cdbc0ac3e837fe53c29e7fcb9917bc;hpb=d240fda92b8bd822645ebeca8831d204746376da;p=hvutilities.git diff --git a/scripts/git-project-update.sh b/scripts/git-project-update.sh index 6fec40b..6b6895f 100755 --- a/scripts/git-project-update.sh +++ b/scripts/git-project-update.sh @@ -2,11 +2,7 @@ SCRIPT="`readlink -e $0`" SCRIPTPATH=$(dirname ${SCRIPT}) - -SUBREPOS_LIST=.gitsubrepos - -# Uncomment to have verbose debug output -##debug=1 +source ${SCRIPTPATH}/hv-git-functions.sh print_usage() { @@ -25,73 +21,20 @@ if [ ${#} -ne 1 ]; then exit 1 fi -if [ ! -f ${SUBREPOS_LIST} ]; then - echo "Missing file for list of subrepos: ${SUBREPOS_LIST}" - print_usage - exit 1 -fi +hv_git_validate_subrepos_list branch=${1} +rc=0 -update_repo() -{ - if [ ${#} -ne 1 ]; then - echo "Missing repository name" - exit 1 - fi - - local r=${1} - - echo "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 - 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 - fi - fi - popd 1> /dev/null -} - -update_repo ./ - -# Read list of repositories from file named .gitsubrepos -while IFS=$'\n' read r ; do - [[ "${r}" =~ \#.* ]] && continue # Skip comment lines - [ -z ${r} ] && continue # Skip enmpty lines - +for r in ./ $(hv_git_get_subrepos_list); do # Make sure directory exists if [ ! -d "${r}" ]; then - echo "Missing repos ${r}" - exit 1 + echo "Skipping missing repos ${r}" + continue fi - # Update only git repos - if [ ! -d "${r}/.git" ]; then - echo "Not a GIT repository" - exit 1 - fi + hv_git_checkout ${r} ${branch} + rc=${?} +done - update_repo ${r} -done < ${SUBREPOS_LIST} +exit ${rc}