Ssh cloning #323

Open
viappidu wants to merge 2 commits from viappidu/ssh_cloning into master
2 changed files with 15 additions and 4 deletions

View File

@@ -11,8 +11,11 @@
# If you omit a branch, it will always default to 'master'
#
# You are allowed to omit the 'https://github.com/' part of the repository URL
# If the repository name starts with 'git@github.com:' SSH will be the method of cloning
# Down below are now a few examples of what is considered as valid:
https://github.com/Klipper3d/klipper,master
https://github.com/Klipper3d/klipper
Klipper3d/klipper,master
Klipper3d/klipper
git@github.com:Klipper3d/klipper,master
git@github.com:Klipper3d/klipper

View File

@@ -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}"
}
}