2022-03-13 12:18:06 +01:00
|
|
|
#!/usr/bin/env bash
|
2022-03-12 18:14:11 +01:00
|
|
|
|
|
|
|
source "$(dirname "$0")/variables.conf"
|
|
|
|
|
2022-03-13 11:40:33 +01:00
|
|
|
for dir in $sync_directory/*; do
|
|
|
|
git -C $dir rev-parse 2>/dev/null >/dev/null
|
|
|
|
if [ "$?" -ne 0 ]; then
|
|
|
|
echo "$dir: not a Git repo"
|
2022-03-12 18:14:11 +01:00
|
|
|
continue
|
|
|
|
fi
|
2022-08-19 21:00:45 +02:00
|
|
|
if [ -f $dir/.disabled ]; then
|
|
|
|
echo "$dir update is disabled."
|
|
|
|
continue
|
|
|
|
fi
|
2022-03-13 11:40:33 +01:00
|
|
|
git -C $dir fetch 2>/dev/null >/dev/null
|
2022-03-12 18:14:11 +01:00
|
|
|
UPSTREAM=${1:-'@{u}'}
|
|
|
|
LOCAL=$(git -C $dir rev-parse @)
|
|
|
|
REMOTE=$(git -C $dir rev-parse "$UPSTREAM")
|
|
|
|
BASE=$(git -C $dir merge-base @ "$UPSTREAM")
|
|
|
|
if [ $LOCAL = $REMOTE ]; then
|
|
|
|
echo "$dir: up-to-date"
|
|
|
|
elif [ $LOCAL = $BASE ]; then
|
|
|
|
echo "pulling $dir"
|
2022-03-13 11:40:33 +01:00
|
|
|
git -C $dir pull 2>/dev/null >/dev/null
|
|
|
|
if [ -e $dir/install.sh ]; then
|
2022-03-13 12:49:18 +01:00
|
|
|
echo "Running $dir's install script..."
|
2022-03-12 18:14:11 +01:00
|
|
|
$dir/install.sh
|
|
|
|
fi
|
|
|
|
elif [ $REMOTE = $BASE ]; then
|
|
|
|
echo "WARNING: $dir is ahead of remote!"
|
|
|
|
else
|
|
|
|
echo "WARNING: $dir and remote have diverged!"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 0
|