Skip to content

Commit

Permalink
fix: allow anonymous cloning on non github pages (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
nwrkbiz authored Mar 8, 2024
1 parent 80fdfb2 commit bac13b6
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions envbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,29 +340,32 @@ 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 {
return fmt.Errorf("parse git url: %w", err)
}
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!")
Expand Down

0 comments on commit bac13b6

Please sign in to comment.