make setgitremote configurable with defaults too

This commit is contained in:
Jakobus Schürz 2023-01-19 10:09:36 +01:00
parent d96652835b
commit 13bf8e8458
3 changed files with 26 additions and 7 deletions

View file

@ -2,14 +2,16 @@
export MSC_GIT_ALL_LOCAL=true
export MSC_GIT_REPO_UPDATE_DEFAULT=true
export MSC_GIT_REPO_UPDATE_INTERVALL_DEFAULT=48 #intervall in hours
export MSC_GIT_REMOTE_NAME_DEFAULT=gitea
export MSC_GIT_BRANCH_DEFAULT=master
export MSC_GIT_SUBMODULES_UPDATE_DEFAULT=true
export MSC_GIT_SUBMODULES_UPDATE_INTERVALL_DEFAULT=196 #intervall in hours
export MSC_GIT_SUBMODULES_SERVER_DEFAULT="git://github.com/"
export MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT="-h"
export MSC_GIT_TIMEOUT_DEFAULT=5s
export MSC_GIT_CHECKOUT_TIMEOUT_DEFAULT=20s
export MSC_GIT_REMOTE_NAME_DEFAULT=gitea
export MSC_GIT_BRANCH_DEFAULT=master
export MSC_GIT_PULLURL_DEFAULT=https://git.schuerz.at/jakob/myshellconfig.git
export MSC_GIT_PUSHURL_DEFAULT=git@git.schuerz.at:jakob/myshellconfig.git
### LOGGING ###
# Possible loglevel-values: ERROR, WARN, INFO, DEBUG, TRACE
export MSC_LOGLEVEL_DEFAULT="WARN"

View file

@ -8,6 +8,10 @@ export MSC_GIT_SUBMODULES_SERVER_DEFAULT="git://github.com/"
export MSC_GIT_CHECKOUTSCRIPT_OPTIONS_DEFAULT="-h"
export MSC_GIT_TIMEOUT_DEFAULT=5s
export MSC_GIT_CHECKOUT_TIMEOUT_DEFAULT=20s
export MSC_GIT_REMOTE_NAME_DEFAULT=gitea
export MSC_GIT_BRANCH_DEFAULT=master
export MSC_GIT_PULLURL_DEFAULT=https://git.schuerz.at/jakob/myshellconfig.git
export MSC_GIT_PUSHURL_DEFAULT=git@git.schuerz.at:jakob/myshellconfig.git
### LOGGING ###
# Possible loglevel-values: ERROR, WARN, INFO, DEBUG, TRACE
export MSC_LOGLEVEL_DEFAULT="INFO"

View file

@ -1338,11 +1338,24 @@ setserver() {
setgitremote() {
cd ~/.local/myshellconfig
git checkout master
git remote set-url origin https://git.schuerz.at/jakob/myshellconfig.git
git remote set-url origin --push git@git.schuerz.at:jakob/myshellconfig.git
loginfo "new remote set to"
git remote -v
git remote get-url ${MSC_GIT_REMOTE_NAME:-$MSC_GIT_REMOTE_NAME_DEFAULT} >/dev/null 2>&1
case $? in
2)
git remote add ${MSC_GIT_REMOTE_NAME:-$MSC_GIT_REMOTE_NAME_DEFAULT} ${MSC_GIT_PULLURL:-$MSC_GIT_PULLURL_DEFAULT}
git fetch ${MSC_GIT_REMOTE_NAME:-$MSC_GIT_REMOTE_NAME_DEFAULT}
;;
*)
echo "no error getting remote url"
;;
esac
git remote set-url ${MSC_GIT_REMOTE_NAME:-$MSC_GIT_REMOTE_NAME_DEFAULT} ${MSC_GIT_PULLURL:-$MSC_GIT_PULLURL_DEFAULT}
git remote set-url --push ${MSC_GIT_REMOTE_NAME:-$MSC_GIT_REMOTE_NAME_DEFAULT} ${MSC_GIT_PUSHURL:-$MSC_GIT_PUSHURL_DEFAULT}
git branch -u "${MSC_GIT_REMOTE_NAME:-$MSC_GIT_REMOTE_NAME_DEFAULT}"/"${MSC_GIT_BRANCH:-$MSC_GIT_BRANCH_DEFAULT}"
git checkout ${MSC_GIT_BRANCH:-$MSC_GIT_BRANCH_DEFAULT}
loginfo "now remotes are: $(git remote -v)"
loginfo "new upstream set to: $(git branch -vv)"
git fetch -p
git merge FETCH_HEAD
git submodule sync