Update git-sync-all

Add extra checks to pull section (ensure directory exists, echo
current dir, set URL)
This commit is contained in:
Evie Litherland-Smith 2024-03-08 08:15:32 +00:00
parent 4be59efb4e
commit f00e8be0a2

View file

@ -15,7 +15,7 @@ SYNC_URLS=(
for i in "${!SYNC_DIRS[@]}"; do
DIRECTORY="${SYNC_DIRS[$i]}"
URL="${SYNC_URLS[$i]}"
echo "--- $DIRECTORY ---"
echo "--- sync: $DIRECTORY ---"
if [ ! -d "$DIRECTORY" ]; then
git clone "$URL" "$DIRECTORY"
fi
@ -27,5 +27,24 @@ for i in "${!SYNC_DIRS[@]}"; do
done
# Pull NixOS and Emacs config if simple fast-forward
git -C /etc/nixos pull --ff-only
git -C "${XDG_CONFIG_HOME:-$HOME/.config}/emacs" pull --ff-only
PULL_DIRS=(
"/etc/nixos"
"${XDG_CONFIG_HOME:-$HOME/.config}/emacs"
)
PULL_URLS=(
"https://git.xenia.me.uk/pixelifytica/nixos.git"
"https://git.xenia.me.uk/pixelifytica/emacs.git"
)
for i in "${!PULL_DIRS[@]}"; do
DIRECTORY="${PULL_DIRS[$i]}"
URL="${PULL_URLS[$i]}"
echo "--- pull: $DIRECTORY ---"
if [ ! -d "$DIRECTORY" ]; then
git clone "$URL" "$DIRECTORY"
fi
(
cd "$DIRECTORY" || exit
git remote set-url origin "$URL"
git pull --ff-only
)
done