From 954e00949f8fdd3bdd9b2b4ae01e4406fcc588f6 Mon Sep 17 00:00:00 2001 From: Ed Shelton <56826122+edshelton@users.noreply.github.com> Date: Thu, 2 Jan 2020 12:50:20 +0000 Subject: [PATCH] Fix broken sed expression and #20 Separates removing the `ssh://` and `git@` prefixes into two expressions. Additionally, replaces `:` with `/`. This means the initial `$GIT_REPO` variable can be something like `git@github.com:my-org/my-repo` and still be cloned by this function, avoiding `URL using bad/illegal format or missing URL` errors. --- src/hrval.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hrval.sh b/src/hrval.sh index 4a70061..8bfea76 100755 --- a/src/hrval.sh +++ b/src/hrval.sh @@ -37,7 +37,7 @@ function clone { ORIGIN=$(git rev-parse --show-toplevel) GIT_REPO=$(yq r ${1} spec.chart.git) if [[ -n "${GITHUB_TOKEN}" ]]; then - BASE_URL=$(echo "${GIT_REPO}" | sed 's/ssh:\/\/git@//') + BASE_URL=$(echo "${GIT_REPO}" | sed -e 's/ssh:\/\///' -e 's/git@//' -e 's/:/\//') GIT_REPO="https://${GITHUB_TOKEN}:x-oauth-basic@${BASE_URL}" fi GIT_REF=$(yq r ${1} spec.chart.ref)