[MISC] Pull main branch name from user git config

This commit is contained in:
yage 2021-11-09 16:48:42 -07:00
parent 1194eb00cf
commit 5d758347ae
3 changed files with 7 additions and 2 deletions

View File

@ -86,7 +86,7 @@ _CA__CLONE_SOURCE() {
&& touch .gitignore \ && touch .gitignore \
&& git add .gitignore \ && git add .gitignore \
&& git commit -m 'project init' \ && git commit -m 'project init' \
&& git remote add "$_CA__GIT_MAIN_BRANCH" $REMOTE_TARGET \ && git remote add $_CA__GET_GIT_MAIN_BRANCH $REMOTE_TARGET \
&& cd .. \ && cd .. \
; ;
} >/dev/null >&1 && echo ' success :)' || echo ' failed :c' } >/dev/null >&1 && echo ' success :)' || echo ' failed :c'

View File

@ -78,6 +78,12 @@ _CA__GET_REMOTE_TARGET() {
echo $REMOTE_TARGET echo $REMOTE_TARGET
} }
_CA__GET_GIT_MAIN_BRANCH() {
{ git config --list | grep 'init.defaultbranch' | sed 's/.*=//' \
|| echo 'main'
} 2>/dev/null
}
_CA__GET_PROJECT_NAME() { _CA__GET_PROJECT_NAME() {
local REMOTE_TARGET="$1" local REMOTE_TARGET="$1"
local DEFAULT_NAME=$(basename $REMOTE_TARGET | sed 's/\.git$//') local DEFAULT_NAME=$(basename $REMOTE_TARGET | sed 's/\.git$//')

View File

@ -22,7 +22,6 @@ export _CA__SOURCE_DIR_NAME='code'
export _CA__VIRTUAL_ENV_NAME='env' export _CA__VIRTUAL_ENV_NAME='env'
export _CA__CUSTOM_ENV_NAME='custom-env' export _CA__CUSTOM_ENV_NAME='custom-env'
export _CA__NO_ENV_SENTINEL='no-env' export _CA__NO_ENV_SENTINEL='no-env'
export _CA__GIT_MAIN_BRANCH='master'
export _CA__CUSTOM_ENV_TEMPLATE="${0:a:h}/custom-env-template.zsh" export _CA__CUSTOM_ENV_TEMPLATE="${0:a:h}/custom-env-template.zsh"