From 36d1f1f112a72b7b1a5b28e989e11606569a054b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sun, 25 Oct 2020 23:04:48 +0100 Subject: [PATCH] configure repo for submodules via env --- bashrc_add | 1 + bin/git-myshellconfig-checkout | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/bashrc_add b/bashrc_add index 9f995bb..42a26fb 100755 --- a/bashrc_add +++ b/bashrc_add @@ -40,6 +40,7 @@ if [[ $- = *i* ]] ; then [ -z "${MYSHELLCONFIG_GIT_CHECKOUT_TIMEOUT+x}" ] && export MYSHELLCONFIG_GIT_CHECKOUT_TIMEOUT=20s [ -z "${MYSHELLCONFIG_GIT_SYNC+x}" ] && export MYSHELLCONFIG_GIT_SYNC=true [ -z "${MYSHELLCONFIG_GIT_UPDATE_SUBMODULES_DEFAULT+x}" ] && export MYSHELLCONFIG_GIT_UPDATE_SUBMODULES_DEFAULT=true + [ -z "${MYSHElLCONFIG_GIT_SUBMODULE_SERVER_DEFUALt+x}" ] && export MYSHElLCONFIG_GIT_SUBMODULE_SERVER_DEFAULT="git://git.schuerz.at/github.com" # hardcoded git export SGIT="git -C ${MYSHELLCONFIG_BASE}" diff --git a/bin/git-myshellconfig-checkout b/bin/git-myshellconfig-checkout index e0bd4dc..705e441 100755 --- a/bin/git-myshellconfig-checkout +++ b/bin/git-myshellconfig-checkout @@ -86,12 +86,20 @@ logdebug "update submodules" rc=0 logdebug "update submodules" >&2 + git config --file=.gitmodules -l | \ + grep url= | \ + awk -F "=" -v srv="${MYSHElLCONFIG_GIT_SUBMODULE_SERVER-${MYSHElLCONFIG_GIT_SUBMODULE_SERVER_DEFAULT}" \ + '{print $1" "gensub(/^.*github.com/,srv,$2)}' | \ + while read a b; do + echo git config --file=.gitmodules "${a}" "${b}" + done + # Submodules always have origin and master as repo and branch to track - $SGIT submodule init 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1|| { logwarn "update submodules failed on ini"; rc=5; } + #$SGIT submodule init 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1|| { logwarn "update submodules failed on ini"; rc=5; } $SGIT submodule sync 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1|| { logwarn "sync submodules failed on sync"; rc=6; } - $SGIT submodule foreach "git checkout master" 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1 || { logwarn "checkout master submodules failed on set upstream"; rc=7; } - $SGIT submodule foreach "git branch -u origin/master master" 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1|| { logwarn "set-upstream submodules failed on set upstream"; rc=8; } - $SGIT submodule update --recursive --remote --merge 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1 || { logwarn " update submodules failed on update"; rc=9; } + #$SGIT submodule foreach "git checkout master" 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1 || { logwarn "checkout master submodules failed on set upstream"; rc=7; } + #$SGIT submodule foreach "git branch -u origin/master master" 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1|| { logwarn "set-upstream submodules failed on set upstream"; rc=8; } + $SGIT submodule update --init --recursive --remote --merge 1>>"${MYSHELLCONFIG_LOGFILE}" 2>&1 || { logwarn " update submodules failed on update"; rc=9; } logdebug "submodules updated" >&2 logdebug "update submodules ENDE"