From 8a4ef0c049a29bec7b38cbf37a3294fe35490059 Mon Sep 17 00:00:00 2001 From: Kjeld Schouten Date: Fri, 25 Oct 2024 17:39:08 +0200 Subject: [PATCH] fix(clustertool): prevent git@ loop-additions --- clustertool/pkg/initfiles/initfiles.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clustertool/pkg/initfiles/initfiles.go b/clustertool/pkg/initfiles/initfiles.go index 2619e4592603d..77b84a3cb740f 100644 --- a/clustertool/pkg/initfiles/initfiles.go +++ b/clustertool/pkg/initfiles/initfiles.go @@ -124,8 +124,10 @@ func FormatGitURL(input string) string { input = "ssh://" + input } - // Replace "github.com/" with "git@github.com:" if present - input = strings.Replace(input, "github.com/", "git@github.com:", 1) + // If the input does not start with "ssh://", add "ssh://" + if !strings.HasPrefix(input, "ssh://git@") { + input = "ssh://git@" + input + } // Compile a regex to match and replace the URL pattern re := regexp.MustCompile(`^ssh://git@github.com:(\w+)/(\w+).git$`)