Add script
This commit is contained in:
parent
1b9a2abcf6
commit
bb6c735355
31
conf-sync.sh
Normal file
31
conf-sync.sh
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source "$(dirname "$0")/variables.conf"
|
||||||
|
|
||||||
|
for dir in $sync_directory; do
|
||||||
|
git -C $dir rev-parse 2>/dev/null
|
||||||
|
if [ "$?" -ne 0 ]; then # ie. this is not a git repo
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
git -C $dir fetch
|
||||||
|
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"
|
||||||
|
git -C pull
|
||||||
|
if []; then
|
||||||
|
echo "Running $dir\'s install script..."
|
||||||
|
$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
|
Loading…
Reference in New Issue
Block a user