From 808b7710266bc3f47bee77c24f059a29264e64b9 Mon Sep 17 00:00:00 2001 From: Daniel G Date: Sat, 10 Feb 2024 22:25:53 +0000 Subject: [PATCH] fix: allow anonymous cloning on non github pages --- envbuilder.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/envbuilder.go b/envbuilder.go index 4a4d4e32..dec0a82f 100644 --- a/envbuilder.go +++ b/envbuilder.go @@ -338,6 +338,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 { @@ -345,22 +355,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!")