From e8bf11c9d9eb85d187bd8da160ca0558d7a388cf Mon Sep 17 00:00:00 2001 From: Lee Brown Date: Thu, 22 Aug 2019 23:42:46 -0800 Subject: [PATCH] fix git remote user --- build/cicd/internal/config/config.go | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/build/cicd/internal/config/config.go b/build/cicd/internal/config/config.go index ad35c01..dc01787 100644 --- a/build/cicd/internal/config/config.go +++ b/build/cicd/internal/config/config.go @@ -581,7 +581,6 @@ func gitRemoteUser(projectRoot string) string { if ev := os.Getenv("CI_PROJECT_PATH"); ev != "" { if strings.Contains(ev, "/") { remoteUrl = strings.Split(ev, "/")[1] - remoteUrl = strings.Split(remoteUrl, "/")[0] } else { remoteUrl = ev } @@ -599,18 +598,20 @@ func gitRemoteUser(projectRoot string) string { break } } + + if remoteUrl == "" { + return "" + } + remoteUrl = strings.TrimSpace(strings.Split(remoteUrl, "=")[1]) + + if !strings.Contains(remoteUrl, ":") { + return "" + } + remoteUrl = strings.Split(remoteUrl, ":")[1] + } - if remoteUrl == "" { - return "" - } - remoteUrl = strings.TrimSpace(strings.Split(remoteUrl, "=")[1]) - - if !strings.Contains(remoteUrl, ":") { - return "" - } - remoteUser := strings.Split(remoteUrl, ":")[1] - remoteUser = strings.Split(remoteUser, "/")[0] - + remoteUser := strings.Split(remoteUrl, "/")[0] + return remoteUser }