From 85095733602be6a735e8509ec4649462ff7c1bb6 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Sun, 25 Aug 2024 19:23:06 +0200 Subject: [PATCH] spcd/git --- spcd/main.sh | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/spcd/main.sh b/spcd/main.sh index a76c3aa..b55d80a 100644 --- a/spcd/main.sh +++ b/spcd/main.sh @@ -886,6 +886,30 @@ spcd_error_os() { exit "${SPCD_ERROR_OS}" } +# ╭───────────┬─────╮ +# │ functions │ git │ +# ╰───────────┴─────╯ + +spcd_git_clone() { + if [ -n "${1}" ]; then + spcd_gc__name="$(basename "${1}")" + spcd_gc__path="${SPCD_DL}/${spcd_gc__name}" + spcd_gc__url="$(spcd_git_url "${1}")" + git clone "${spcd_gc__url}" "${spcd_gc__path}" + echo "${spcd_gc__path}" + fi +} + +spcd_git_url() { + if [ -n "${1}" ]; then + case "${1}" in + http*) echo "${1}" ;; + */*) echo "${SPCD_PROJECT_ROOT}/${1}" ;; + *) echo "${SPCD_PROJECT_ROOT}/${SPCD_PROJECT_PATH}/${1}" ;; + esac + fi +} + # ╭───────────┬──────╮ # │ functions │ step │ # ╰───────────┴──────╯ @@ -934,26 +958,6 @@ spcd_echo() { fi } -spcd_git_clone() { - if [ -n "${1}" ]; then - spcd_gc__name="$(basename "${1}")" - spcd_gc__path="${SPCD_DL}/${spcd_gc__name}" - spcd_gc__url="$(spcd_git_url "${1}")" - git clone "${spcd_gc__url}" "${spcd_gc__path}" - echo "${spcd_gc__path}" - fi -} - -spcd_git_url() { - if [ -n "${1}" ]; then - case "${1}" in - http*) echo "${1}" ;; - */*) echo "${SPCD_PROJECT_ROOT}/${1}" ;; - *) echo "${SPCD_PROJECT_ROOT}/${SPCD_PROJECT_PATH}/${1}" ;; - esac - fi -} - spcd_grep_os() { spcd_grep_os__variable="${1}" [ -n "${spcd_grep_os__variable}" ] &&