From f00e8be0a2fb2b737e3349238ed8436b1dc359e3 Mon Sep 17 00:00:00 2001 From: Evie Litherland-Smith Date: Fri, 8 Mar 2024 08:15:32 +0000 Subject: [PATCH] Update git-sync-all Add extra checks to pull section (ensure directory exists, echo current dir, set URL) --- home/scripts/git-sync-all.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/home/scripts/git-sync-all.sh b/home/scripts/git-sync-all.sh index 2a15362a..6dfb923c 100755 --- a/home/scripts/git-sync-all.sh +++ b/home/scripts/git-sync-all.sh @@ -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