From f9d3c542cd8a645c3cabb6a9a78df816bab98e9a Mon Sep 17 00:00:00 2001 From: laggardkernel Date: Sat, 14 Aug 2021 15:41:26 +0800 Subject: [PATCH] Remove hardcoding default branch as "master" Default branch of repo could be "master", "main" or any names. Stop hardcoding "master" as the default to clone and let "git" decide it automatically. --- scripts/install_plugins.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/install_plugins.sh b/scripts/install_plugins.sh index 3c5e200..cd75e7a 100755 --- a/scripts/install_plugins.sh +++ b/scripts/install_plugins.sh @@ -13,9 +13,14 @@ else # shell output functions fi clone() { - local plugin="$1" - cd "$(tpm_path)" && - GIT_TERMINAL_PROMPT=0 git clone -b "$branch" --single-branch --recursive "$plugin" >/dev/null 2>&1 + local plugin="$1" branch="$2" + if [ -n "$branch" ]; then + cd "$(tpm_path)" && + GIT_TERMINAL_PROMPT=0 git clone -b "$branch" --single-branch --recursive "$plugin" >/dev/null 2>&1 + else + cd "$(tpm_path)" && + GIT_TERMINAL_PROMPT=0 git clone --single-branch --recursive "$plugin" >/dev/null 2>&1 + fi } # tries cloning: @@ -30,8 +35,7 @@ clone_plugin() { # clone plugin and produce output install_plugin() { - local plugin="$1" - local branch=`[ -z "$2" ] && echo "master" || echo "$2"` + local plugin="$1" branch="$2" local plugin_name="$(plugin_name_helper "$plugin")" if plugin_already_installed "$plugin"; then