File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -234,7 +234,7 @@ function _bash-it-update-() {
234234 fi
235235
236236 if [[ -z " $BASH_IT_REMOTE " ]]; then
237- BASH_IT_REMOTE=" origin "
237+ BASH_IT_REMOTE=$( _remote_name )
238238 fi
239239
240240 git fetch " $BASH_IT_REMOTE " --tags & > /dev/null
@@ -352,7 +352,7 @@ function _bash-it-version() {
352352 pushd " ${BASH_IT?} " > /dev/null || return
353353
354354 if [[ -z " ${BASH_IT_REMOTE:- } " ]]; then
355- BASH_IT_REMOTE=" origin "
355+ BASH_IT_REMOTE=$( _remote_name )
356356 fi
357357
358358 BASH_IT_GIT_REMOTE=" $( git remote get-url " $BASH_IT_REMOTE " ) "
@@ -1233,6 +1233,24 @@ function pathmunge() {
12331233 fi
12341234}
12351235
1236+ function _remote_name() {
1237+ local branch
1238+ branch=$( git branch --show-current)
1239+
1240+ local remote_name=
1241+ remote_name=$( git config --get --default ' ' " branch.$branch .remote" )
1242+ if [[ -n " $remote_name " ]]; then
1243+ printf ' %s\n' " $remote_name "
1244+ return
1245+ fi
1246+
1247+ if remote_name=$( git remote -v | awk ' NR==1 { name=$1; print name } $1 != name { exit 1 }' ) ; then
1248+ printf ' %s\n' " $remote_name "
1249+ else
1250+ printf ' %s\n' ' origin'
1251+ fi
1252+ }
1253+
12361254# `_bash-it-find-in-ancestor` uses the shell's ability to run a function in
12371255# a subshell to simplify our search to a simple `cd ..` and `[[ -r $1 ]]`
12381256# without any external dependencies. Let the shell do what it's good at.
You can’t perform that action at this time.
0 commit comments