From a1898c03b53b29e003037e0c94690d98e7a60e94 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Thu, 16 Jul 2026 15:33:33 -0700 Subject: [PATCH] Move checking git projects via code-check to shared and make it generic. Code-check will reference it. --- rc_shared.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/rc_shared.sh b/rc_shared.sh index 98e6034..05a2ee1 100644 --- a/rc_shared.sh +++ b/rc_shared.sh @@ -825,6 +825,39 @@ alias exec-html="run-site" alias site-host="run-site" alias host-site="run-site" +function git-check { + dir="`pwd`" + if [[ -n "$1" ]]; then + dir="$1" + fi + + echo "Checking '$dir' for git changes." + ls -d "$dir"/* | while read project; do + if [[ ! -d $project ]]; then + continue + fi + echo -e "\n*** `basename $project` ***" + cd $project + if [[ -d .git ]]; then + git ls-remote --exit-code --heads origin dev + dev_exists="$?" + if [[ "$dev_exists" == 0 ]]; then + git switch dev + elif [[ "$dev_exists" == 2 ]]; then + git switch main + else + echo "ERROR: Unknown status for dev_exists, '$dev_exists'." + continue + fi + git pull + git push + else + echo "Not a Git project, skipping!" + fi + done + echo -e "\nDone!" +} + ## Finalize ##