From 93302dc2de1cb270d0fe912bdb61a4973a07ad3b Mon Sep 17 00:00:00 2001 From: avcopan Date: Fri, 24 Jan 2025 11:41:04 -0600 Subject: [PATCH] New: Safer prompting + update amech-dev fork if accessible --- scripts/update.sh | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/scripts/update.sh b/scripts/update.sh index 86498b6..1b28a8d 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -20,25 +20,40 @@ BRANCH=${2:-dev} FLAGS=${@:3} # 1. Update the amech-dev repo +git checkout main git pull https://github.com/Auto-Mech/amech-dev pixi self-update pixi install # 2. Loop through each repo and update -echo "Execute the following commands in each repository?" +echo "The following commands will be run in each repository:" echo " git checkout ${BRANCH}" echo " git pull --rebase ${REMOTE} ${BRANCH}" echo " git push ${FLAGS} origin ${BRANCH}" -read -p "Press enter to confirm " - -for repo in ${REPOS[@]} -do - printf "\n*** Updating in ${DIR}/src/${repo} ***\n" - ( - cd ${DIR}/src/${repo} && \ - git checkout ${BRANCH} && \ - git pull --rebase ${REMOTE} ${BRANCH} && \ - git push ${FLAGS} origin ${BRANCH} - ) - printf "******\n" -done +read -p "Is this what you want to do? [y/n] " yn + +if [[ $yn =~ ^[Yy]$ ]]; then + for repo in ${REPOS[@]} + do + printf "\n*** Updating in ${DIR}/src/${repo} ***\n" + ( + cd ${DIR}/src/${repo} && \ + git checkout ${BRANCH} && \ + git pull --rebase ${REMOTE} ${BRANCH} && \ + git push ${FLAGS} origin ${BRANCH} + ) + printf "******\n" + done +fi + +if git config --get remote.origin.url | grep -i Auto-Mech > /dev/null; then + echo "No fork of amech-dev found. Not attempting to push amech-dev." +else + echo "You appear to be working on a fork of amech-dev." + read -p "Do you want to push amech-dev changes to your fork? [y/n] " yn + if [[ $yn =~ ^[Yy]$ ]]; then + git push origin + fi +fi + +git checkout -