From bac13b6ebe20c064ba7f4e2372f353694e1dfdc7 Mon Sep 17 00:00:00 2001 From: Daniel G Date: Fri, 8 Mar 2024 17:48:32 +0100 Subject: [PATCH] fix: allow anonymous cloning on non github pages (#87) --- envbuilder.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/envbuilder.go b/envbuilder.go index e1db216f..ecef41d5 100644 --- a/envbuilder.go +++ b/envbuilder.go @@ -340,6 +340,16 @@ func Run(ctx context.Context, options Options) error { } }() + cloneOpts := CloneRepoOptions{ + Path: options.WorkspaceFolder, + Storage: options.Filesystem, + Insecure: options.Insecure, + Progress: writer, + SingleBranch: options.GitCloneSingleBranch, + Depth: options.GitCloneDepth, + CABundle: caBundle, + } + if options.GitUsername != "" || options.GitPassword != "" { gitURL, err := url.Parse(options.GitURL) if err != nil { @@ -347,22 +357,15 @@ func Run(ctx context.Context, options Options) error { } gitURL.User = url.UserPassword(options.GitUsername, options.GitPassword) options.GitURL = gitURL.String() - } - cloned, fallbackErr = CloneRepo(ctx, CloneRepoOptions{ - Path: options.WorkspaceFolder, - Storage: options.Filesystem, - RepoURL: options.GitURL, - Insecure: options.Insecure, - Progress: writer, - RepoAuth: &githttp.BasicAuth{ + cloneOpts.RepoAuth = &githttp.BasicAuth{ Username: options.GitUsername, Password: options.GitPassword, - }, - SingleBranch: options.GitCloneSingleBranch, - Depth: options.GitCloneDepth, - CABundle: caBundle, - }) + } + } + cloneOpts.RepoURL = options.GitURL + + cloned, fallbackErr = CloneRepo(ctx, cloneOpts) if fallbackErr == nil { if cloned { endStage("📦 Cloned repository!")