Print messages and check correct branch for updates

This commit is contained in:
southerntofu 2020-04-17 22:43:14 -04:00
parent 281dec5414
commit f5f33f19bc
1 changed files with 17 additions and 9 deletions

View File

@ -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