From 933555883a349b0f26d090dcd763cf39f61c3678 Mon Sep 17 00:00:00 2001 From: Fabio Viappiani Date: Fri, 31 Mar 2023 11:06:47 +0200 Subject: [PATCH] Update klipper.sh Checkig if clone is via ssh --- scripts/klipper.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/klipper.sh b/scripts/klipper.sh index 27483cb..c43e696 100644 --- a/scripts/klipper.sh +++ b/scripts/klipper.sh @@ -251,16 +251,24 @@ function run_klipper_setup() { function clone_klipper() { local repo=${1} branch=${2} + + [[ -z ${repo} ]] && repo="${KLIPPER_REPO}" - repo=$(echo "${repo}" | sed -r "s/^(http|https):\/\/github\.com\///i; s/\.git$//") - repo="https://github.com/${repo}" + if [[ "$repo" != "git@github.com:"* ]]; then + clone_method="https" + repo=$(echo "${repo}" | sed -r "s/^(http|https):\/\/github\.com\///i; s/\.git$//") + repo="https://github.com/${repo}" + else + clone_method="ssh" + repo=$(echo "${repo}") + fi [[ -z ${branch} ]] && branch="master" ### force remove existing klipper dir and clone into fresh klipper dir [[ -d ${KLIPPER_DIR} ]] && rm -rf "${KLIPPER_DIR}" - status_msg "Cloning Klipper from ${repo} ..." + status_msg "Cloning Klipper from ${repo} using ${clone_method} ..." cd "${HOME}" || exit 1 if git clone "${repo}" "${KLIPPER_DIR}"; then @@ -628,4 +636,4 @@ function get_klipper_python_ver() { local version version=$("${KLIPPY_ENV}"/bin/python --version 2>&1 | cut -d" " -f2 | cut -d"." -f1) echo "${version}" -} \ No newline at end of file +}