From 5d758347aeb47e582bc62d9fff7387ddebe169ce Mon Sep 17 00:00:00 2001 From: yage Date: Tue, 9 Nov 2021 16:48:42 -0700 Subject: [PATCH] [MISC] Pull main branch name from user git config --- zsh/clone.zsh | 2 +- zsh/helpers.zsh | 6 ++++++ zsh/settings.zsh | Bin 1216 -> 1179 bytes 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/zsh/clone.zsh b/zsh/clone.zsh index ccc152f..8d62b2f 100644 --- a/zsh/clone.zsh +++ b/zsh/clone.zsh @@ -86,7 +86,7 @@ _CA__CLONE_SOURCE() { && touch .gitignore \ && git add .gitignore \ && 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 .. \ ; } >/dev/null >&1 && echo ' success :)' || echo ' failed :c' diff --git a/zsh/helpers.zsh b/zsh/helpers.zsh index f68c007..f8acb44 100644 --- a/zsh/helpers.zsh +++ b/zsh/helpers.zsh @@ -78,6 +78,12 @@ _CA__GET_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() { local REMOTE_TARGET="$1" local DEFAULT_NAME=$(basename $REMOTE_TARGET | sed 's/\.git$//') diff --git a/zsh/settings.zsh b/zsh/settings.zsh index 1461e5e69e85b238f71b9ab218fc3c524f090638..d26b10249eba5e6d520e533f094ee3b40f55f518 100644 GIT binary patch delta 12 TcmX@WIh%7s2=nGjW_Lya9j62A delta 48 zcmbQud4O|62(xl(ML~X1i9)=yV|={3XGpxSqo-fIQ;?&dvxlvEZenpsYSHE(W=}={ DjLHwP