From 5ae7dc8cf7e5abd6642cb97782e4b84363e7ef90 Mon Sep 17 00:00:00 2001 From: RealStickman Date: Thu, 30 Jun 2022 15:00:13 +0200 Subject: [PATCH] Automatically detect local repos and update all of them --- arch-config/scripts/in_path/sc-git-pull | 78 +++++-------------------- 1 file changed, 14 insertions(+), 64 deletions(-) diff --git a/arch-config/scripts/in_path/sc-git-pull b/arch-config/scripts/in_path/sc-git-pull index 93d43ff6..e3d6e55d 100755 --- a/arch-config/scripts/in_path/sc-git-pull +++ b/arch-config/scripts/in_path/sc-git-pull @@ -7,70 +7,20 @@ fi WORKPATH="$HOME/GitProjects" -if [ ! -d "$HOME/GitProjects/config" ]; then - git -C $WORKPATH clone git@gitlab.com:RealStickman-arch/config.git -fi -cd "$HOME/GitProjects/config" -git fetch --all -git pull +readarray -t dirs < <(find "$WORKPATH" -mindepth 1 -maxdepth 1 -type d -printf '%P\n') -if [ ! -d "$HOME/GitProjects/grab" ]; then - git -C $WORKPATH clone git@gitlab.com:RealStickman/grab.git -fi -cd "$HOME/GitProjects/grab" -git fetch --all -git pull - -: ' -if [ ! -d "$HOME/GitProjects/powershell-scripting" ]; then - git -C $WORKPATH clone git@gitlab.com:RealStickman/powershell-scripting.git -fi -cd "$HOME/GitProjects/powershell-scripting" -git fetch --all -git pull -' - -if [ ! -d "$HOME/GitProjects/setup" ]; then - git -C $WORKPATH clone git@gitlab.com:RealStickman-arch/setup.git -fi -cd "$HOME/GitProjects/setup" -git fetch --all -git pull - -if [ ! -d "$HOME/GitProjects/themes" ]; then - git -C $WORKPATH clone git@gitlab.com:RealStickman-arch/themes.git -fi -cd "$HOME/GitProjects/themes" -git fetch --all -git pull -: ' -if [ ! -d "$HOME/GitProjects/setup-pinephone" ]; then - git -C $WORKPATH clone git@gitlab.com:RealStickman/setup-pinephone.git -fi -cd "$HOME/GitProjects/setup-pinephone" -git fetch --all -git pull -' - -if [ ! -d "$HOME/GitProjects/website" ]; then - git -C $WORKPATH clone git@gitlab.com:RealStickman/website.git -fi -cd "$HOME/GitProjects/website" -git fetch --all -git pull - -if [ ! -d "$HOME/GitProjects/arch-autobuild-pkg" ]; then - git -C $WORKPATH clone git@gitlab.com:arch-pkgbuilds/arch-autobuild-pkg.git -fi -cd "$HOME/GitProjects/arch-autobuild-pkg" -git fetch --all -git pull - -if [ ! -d "$HOME/GitProjects/ssh" ]; then - git -C $WORKPATH clone git@gitlab.com:RealStickman/ssh.git -fi -cd "$HOME/GitProjects/ssh" -git fetch --all -git pull +for dir in "${dirs[@]}"; do + # go into GitProjects directory + cd "$WORKPATH" + # output directory you're currently working on + printf "Working on ${dir}\n" + # change into that directory + cd "$dir" + # try to check out master or main branch + git checkout -q master \ + || git checkout -q main + git fetch --all + git pull origin +done exit 0