Add guard for git-sync-all for non-main branch

Only pull/push non-syncing repos (currently nixos and emacs) if on the
"main" branch, echo warning message and skip otherwise.
This commit is contained in:
Evie Litherland-Smith 2024-04-11 23:08:55 +01:00 committed by Evie Litherland-Smith
parent f8c7f1bf55
commit 5db0b3feff

View file

@ -46,8 +46,12 @@ for i in "${!PULL_DIRS[@]}"; do
fi
(
cd "$DIRECTORY" || exit
git remote set-url origin "$URL"
git pull --ff-only
git push
if [ "$(git branch --show-current)" = "main" ]; then
git remote set-url origin "$URL"
git pull --ff-only
git push
else
echo "Not syncing repo $DIRECTORY on branch $(git branch --show-current)"
fi
)
done