diff --git a/git-build.sh b/git-build.sh index e4c93d3..03c78dd 100755 --- a/git-build.sh +++ b/git-build.sh @@ -5,21 +5,29 @@ BASEDIR="$HOME/.git-build" for project in $BASEDIR/*.source; do p_name="$(basename $project .source)" + echo "[$p_name] START" + [ -f $BASEDIR/$p_name.branch ] && p_branch="$(cat $BASEDIR/$p_name.branch)" || p_branch="master" +echo "$branch" p_dir="$BASEDIR/.$p_name" if [ ! -d $p_dir ]; then - git clone "$(cat $BASEDIR/$p_name.source)" "$p_dir" - if [ -f $BASEDIR/$p_name.branch ]; then + source="$(cat $BASEDIR/$p_name.source)" + echo "[$p_name] CLONE $source" + git clone "$source" "$p_dir" + [[ $? != 0 ]] && echo "[$p_name] CLONE FAILED" && exit 1 + if [[ "$p_branch" != "master" ]]; then cd $p_dir - git checkout "$(cat $BASEDIR/$p_name.branch)" + echo "[$p_name] CHECKOUT BRANCH $p_branch" + git checkout "$p_branch" + [[ $? != 0 ]] && echo "[$p_name] CHECKOUT FAILED" && exit 1 fi fi - if [ ! -d $p_dir ]; then - echo "ERROR: could not create repo for project $project" - exit 1 - fi cd "$p_dir" - if ! git diff --quiet remotes/origin/HEAD; then + git diff --quiet remotes/origin/$p_branch + if [[ $? != 0 ]]; then + echo "[$p_name] PULL" git pull + [[ $? != 0 ]] && echo "[$p_name] PULL FAILED" && exit 1 + echo "[$p_name] RUN" + GITBUILDDIR="$BASEDIR" eval "$BASEDIR/$p_name $p_name" fi - GITBUILDDIR="$BASEDIR" eval "$BASEDIR/$p_name $p_name" done