From 025b6a51dd7a66f46d0fcaf1acc9fabb3201b938 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Thu, 17 Jul 2014 21:37:50 +0200 Subject: [PATCH] Cleanups, error checking and other robustness --- bin/update_repos | 76 +++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 46 deletions(-) diff --git a/bin/update_repos b/bin/update_repos index 44cdc22..3a38954 100755 --- a/bin/update_repos +++ b/bin/update_repos @@ -9,62 +9,46 @@ if [ ! -e $WORKSPACE ]; then mkdir -p $WORKSPACE fi -#GRPS=`cat ~/.git_groups` -#GRPS=$(<~/.git_groups) -#GRPS=$(<$HOME/.privdotfiles/git_groups) -echo `pwd` - saveIFS="$IFS" IFS=$'\n' GRPS=($(<~/.git_groups)) IFS="$saveIFS" -#echo ${GRPS[0]} - -#GRPS=$( 0 ]; then - echo -e "[\e[31mX\e[0m] $GRP/$REPODIR changed - $WORKSPACE/$GRP/$REPO" + for REPO in "${REPOS[@]}"; do + cd $WORKSPACE/$GRP + REPODIR=$(basename "$REPO") + #extension="${filename##*.}" + REPODIR="${REPODIR%.*}" + if [ -e $REPODIR ]; then + cd $REPODIR + #git diff --quiet || echo "[c] skipping" + git diff --quiet + if [ $? > 0 ]; then + echo -e "[\e[31mX\e[0m] $GRP/$REPODIR changed - $WORKSPACE/$GRP/$REPO" + else + echo -e "[\e[32mU\e[0m] $GRP/$REPODIR" + #git pull + fi else - echo -e "[\e[32mU\e[0m] $GRP/$REPODIR" - #git pull + #git clone $REPO + echo -e "[\e[33mC\e[0m] $GRP/$REPODIR" fi - else - #git clone $REPO - echo -e "[\e[33mC\e[0m] $GRP/$REPODIR" - fi - done + done + else + echo -e "[\e[31mX\e[0m] Group config file ~/.git_group_$GRP not found" + fi done