From b8f1eadb7f2bd82d552deaab6086230bca634420 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 8 Mar 2017 13:57:35 -0800 Subject: [PATCH] Shift off `checkout` from being passed to script from `pihole` Signed-off-by: Dan Schaper --- advanced/Scripts/piholeCheckout.sh | 17 +++++++++++------ pihole | 1 + 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/advanced/Scripts/piholeCheckout.sh b/advanced/Scripts/piholeCheckout.sh index 1c6711f4..94ae5a16 100644 --- a/advanced/Scripts/piholeCheckout.sh +++ b/advanced/Scripts/piholeCheckout.sh @@ -9,7 +9,7 @@ # Please see LICENSE file for your rights under this license. readonly PI_HOLE_FILES_DIR="/etc/.pihole" -PH_TEST=true source ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh +PH_TEST="true" source ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh # webInterfaceGitUrl set in basic-install.sh # webInterfaceDir set in basic-install.sh @@ -21,7 +21,11 @@ fully_fetch_repo() { local directory="${1}" cd "${directory}" || return 1 - git fetch --quiet --unshallow || return 1 + if is_repo "${directory}"; then + git fetch --quiet --unshallow &> /dev/null || true # Deep repo's cause errors but are valid repos. + else + return 1 + fi return 0 } @@ -107,7 +111,7 @@ checkout() echo "::: ${#webbranches[@]} branches available" echo ":::" - if [[ "${2}" == "dev" ]] ; then + if [[ "${1}" == "dev" ]] ; then # Shortcut to check out development branches echo "::: Shortcut \"dev\" detected - checking out development / devel branches ..." echo "::: Pi-hole core" @@ -115,7 +119,7 @@ checkout() echo "::: Web interface" checkout_pull_branch "${webInterfaceDir}" "devel" echo "::: done!" - elif [[ "${2}" == "master" ]] ; then + elif [[ "${1}" == "master" ]] ; then # Shortcut to check out master branches echo "::: Shortcut \"master\" detected - checking out master branches ..." echo "::: Pi-hole core" @@ -123,7 +127,7 @@ checkout() echo "::: Web interface" checkout_pull_branch "${webInterfaceDir}" "master" echo "::: done!" - elif [[ "${2}" == "core" ]] ; then + elif [[ "${1}" == "core" ]] ; then # Have to user chosing the branch he wants if ! (for e in "${corebranches[@]}"; do [[ "$e" == "${3}" ]] && exit 0; done); then echo "::: Requested branch \"${3}\" is not available!" @@ -132,7 +136,7 @@ checkout() exit 1 fi checkout_pull_branch "${PI_HOLE_FILES_DIR}" "${3}" - elif [[ "${2}" == "web" ]] ; then + elif [[ "${1}" == "web" ]] ; then # Have to user chosing the branch he wants if ! (for e in "${webbranches[@]}"; do [[ "$e" == "${3}" ]] && exit 0; done); then echo "::: Requested branch \"${3}\" is not available!" @@ -152,3 +156,4 @@ checkout() exit 0 } + diff --git a/pihole b/pihole index 38c7160f..dda6d750 100755 --- a/pihole +++ b/pihole @@ -281,6 +281,7 @@ tailFunc() { piholeCheckoutFunc() { source "${PI_HOLE_SCRIPT_DIR}"/piholeCheckout.sh + shift checkout "$@" }