lib/theme: new `_bash_it_appearance_scm_init()`
Wrap init code in a function and call the function immediately. Several plugins do this, and it allows us to more easily implement a hooks-based system in the future. Alsö, avoid external binary `which`. Use built-in `type -P` instead. Uppercase `-P` forces a path search to avoid hashed matches and functions/aliases and whatnot.pull/1909/head
parent
9c1dbbcf12
commit
476fcb4325
|
|
@ -7,7 +7,6 @@ load ../../lib/log
|
||||||
cite _about _param _example _group _author _version
|
cite _about _param _example _group _author _version
|
||||||
|
|
||||||
load ../../lib/helpers
|
load ../../lib/helpers
|
||||||
load ../../themes/base.theme
|
|
||||||
|
|
||||||
function local_setup {
|
function local_setup {
|
||||||
setup_test_fixture
|
setup_test_fixture
|
||||||
|
|
@ -23,6 +22,8 @@ function local_setup {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export OLD_PATH="$PATH"
|
export OLD_PATH="$PATH"
|
||||||
|
|
||||||
|
load ../../themes/base.theme
|
||||||
}
|
}
|
||||||
|
|
||||||
function local_teardown {
|
function local_teardown {
|
||||||
|
|
@ -56,8 +57,8 @@ function setup_svn_path {
|
||||||
|
|
||||||
setup_svn_path "$BASH_IT/test/fixtures/svn/working"
|
setup_svn_path "$BASH_IT/test/fixtures/svn/working"
|
||||||
|
|
||||||
# Load the base theme again so that the working SVN script is detected
|
# Init the base theme again so that the working SVN script is detected
|
||||||
load ../../themes/base.theme
|
_bash_it_appearance_scm_init
|
||||||
|
|
||||||
scm
|
scm
|
||||||
# Make sure that the SVN command is used
|
# Make sure that the SVN command is used
|
||||||
|
|
@ -73,8 +74,8 @@ function setup_svn_path {
|
||||||
|
|
||||||
setup_svn_path "$BASH_IT/test/fixtures/svn/working"
|
setup_svn_path "$BASH_IT/test/fixtures/svn/working"
|
||||||
|
|
||||||
# Load the base theme again so that the working SVN script is detected
|
# init the base theme again so that the working SVN script is detected
|
||||||
load ../../themes/base.theme
|
_bash_it_appearance_scm_init
|
||||||
|
|
||||||
scm
|
scm
|
||||||
# Make sure that the SVN command is used
|
# Make sure that the SVN command is used
|
||||||
|
|
@ -89,8 +90,8 @@ function setup_svn_path {
|
||||||
|
|
||||||
setup_svn_path "$BASH_IT/test/fixtures/svn/working"
|
setup_svn_path "$BASH_IT/test/fixtures/svn/working"
|
||||||
|
|
||||||
# Load the base theme again so that the working SVN script is detected
|
# Init the base theme again so that the working SVN script is detected
|
||||||
load ../../themes/base.theme
|
_bash_it_appearance_scm_init
|
||||||
|
|
||||||
scm
|
scm
|
||||||
# Make sure that no SVN command is used
|
# Make sure that no SVN command is used
|
||||||
|
|
@ -103,8 +104,8 @@ function setup_svn_path {
|
||||||
|
|
||||||
setup_svn_path "$BASH_IT/test/fixtures/svn/broken"
|
setup_svn_path "$BASH_IT/test/fixtures/svn/broken"
|
||||||
|
|
||||||
# Load the base theme again so that the broken SVN script is detected
|
# Init the base theme again so that the broken SVN script is detected
|
||||||
load ../../themes/base.theme
|
_bash_it_appearance_scm_init
|
||||||
|
|
||||||
scm
|
scm
|
||||||
# Make sure that no SVN command is not used
|
# Make sure that no SVN command is not used
|
||||||
|
|
@ -120,8 +121,8 @@ function setup_svn_path {
|
||||||
|
|
||||||
setup_svn_path "$BASH_IT/test/fixtures/svn/broken"
|
setup_svn_path "$BASH_IT/test/fixtures/svn/broken"
|
||||||
|
|
||||||
# Load the base theme again so that the broken SVN script is detected
|
# Init the base theme again so that the broken SVN script is detected
|
||||||
load ../../themes/base.theme
|
_bash_it_appearance_scm_init
|
||||||
|
|
||||||
scm
|
scm
|
||||||
# Make sure that no SVN command is used
|
# Make sure that no SVN command is used
|
||||||
|
|
|
||||||
|
|
@ -85,19 +85,27 @@ RBENV_THEME_PROMPT_SUFFIX='|'
|
||||||
RBFU_THEME_PROMPT_PREFIX=' |'
|
RBFU_THEME_PROMPT_PREFIX=' |'
|
||||||
RBFU_THEME_PROMPT_SUFFIX='|'
|
RBFU_THEME_PROMPT_SUFFIX='|'
|
||||||
|
|
||||||
GIT_EXE=$(which git 2> /dev/null || true)
|
: "${GIT_EXE:=$SCM_GIT}"
|
||||||
P4_EXE=$(which p4 2> /dev/null || true)
|
: "${P4_EXE:=$SCM_P4}"
|
||||||
HG_EXE=$(which hg 2> /dev/null || true)
|
: "${HG_EXE:=$SCM_HG}"
|
||||||
SVN_EXE=$(which svn 2> /dev/null || true)
|
: "${SVN_EXE:=$SCM_SVN}"
|
||||||
|
|
||||||
# Check for broken SVN exe that is caused by some versions of Xcode.
|
function _bash_it_appearance_scm_init() {
|
||||||
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
|
GIT_EXE="$(type -P $SCM_GIT || true)"
|
||||||
if [[ -x "$SVN_EXE" && -x "${SVN_EXE%/*}/xcrun" ]]; then
|
P4_EXE="$(type -P $SCM_P4 || true)"
|
||||||
if ! "$SVN_EXE" --version > /dev/null 2>&1; then
|
HG_EXE="$(type -P $SCM_HG || true)"
|
||||||
# Unset the SVN exe variable so that SVN commands are avoided.
|
SVN_EXE="$(type -P $SCM_SVN || true)"
|
||||||
SVN_EXE=""
|
|
||||||
|
# Check for broken SVN exe that is caused by some versions of Xcode.
|
||||||
|
# See https://github.com/Bash-it/bash-it/issues/1612 for more details.
|
||||||
|
if [[ -x "$SVN_EXE" && -x "${SVN_EXE%/*}/xcrun" ]]; then
|
||||||
|
if ! "$SVN_EXE" --version > /dev/null 2>&1; then
|
||||||
|
# Unset the SVN exe variable so that SVN commands are avoided.
|
||||||
|
SVN_EXE=""
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
}
|
||||||
|
_bash_it_appearance_scm_init
|
||||||
|
|
||||||
function scm {
|
function scm {
|
||||||
if [[ "$SCM_CHECK" = false ]]; then
|
if [[ "$SCM_CHECK" = false ]]; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue