diff --git a/changelog/pending/20221006--cli-new--fix-ado-repos.yaml b/changelog/pending/20221006--cli-new--fix-ado-repos.yaml new file mode 100644 index 000000000000..5af91212f69a --- /dev/null +++ b/changelog/pending/20221006--cli-new--fix-ado-repos.yaml @@ -0,0 +1,4 @@ +changes: +- type: fix + scope: cli/new + description: Fix cloning templates from Azure DevOps repos. diff --git a/sdk/go/common/util/gitutil/git.go b/sdk/go/common/util/gitutil/git.go index f8227ab466bf..f51b0d80d58a 100644 --- a/sdk/go/common/util/gitutil/git.go +++ b/sdk/go/common/util/gitutil/git.go @@ -32,6 +32,7 @@ import ( "github.com/go-git/go-git/v5/storage/memory" "github.com/pkg/errors" "github.com/pulumi/pulumi/sdk/v3/go/common/util/fsutil" + "github.com/pulumi/pulumi/sdk/v3/go/common/util/logging" ) // VCSKind represents the hostname of a specific type of VCS. @@ -280,6 +281,7 @@ func GitCloneAndCheckoutCommit(url string, commit plumbing.Hash, path string) er } func GitCloneOrPull(rawurl string, referenceName plumbing.ReferenceName, path string, shallow bool) error { + logging.V(10).Infof("Attempting to clone from %s at ref %s", rawurl, referenceName) if u, err := url.Parse(rawurl); err == nil && u.Hostname() == AzureDevOpsHostName { // system-installed git is used to clone Azure DevOps repositories // due to https://github.com/go-git/go-git/issues/64 @@ -346,7 +348,7 @@ func gitCloneOrPullSystemGit(url string, referenceName plumbing.ReferenceName, p if _, err := os.Stat(filepath.Join(path, ".git")); os.IsNotExist(err) { // Repo does not exist, clone it. gitArgs = []string{ - "clone", url, + "clone", url, ".", } // For shallow clones, use a depth of 1. if shallow { diff --git a/sdk/go/common/workspace/templates.go b/sdk/go/common/workspace/templates.go index 334ba1b99357..4b2f21632c6a 100644 --- a/sdk/go/common/workspace/templates.go +++ b/sdk/go/common/workspace/templates.go @@ -30,6 +30,7 @@ import ( "github.com/pulumi/pulumi/sdk/v3/go/common/util/contract" "github.com/pulumi/pulumi/sdk/v3/go/common/util/gitutil" + "github.com/pulumi/pulumi/sdk/v3/go/common/util/logging" ) const ( @@ -373,8 +374,9 @@ func RetrieveGitFolder(rawurl string, path string) (string, error) { if err != nil { return "", fmt.Errorf("failed to get git ref: %w", err) } - if ref != "" { + logging.V(10).Infof("Attempting to fetch from %s at commit %s@%s for subdirectory '%s'", url, ref, commit, subDirectory) + if ref != "" { // Different reference attempts to cycle through // We default to master then main in that order. We need to order them to avoid breaking // already existing processes for repos that already have a master and main branch. @@ -405,6 +407,7 @@ func RetrieveGitFolder(rawurl string, path string) (string, error) { // Verify the sub directory exists. fullPath := filepath.Join(path, filepath.FromSlash(subDirectory)) + logging.V(10).Infof("Cloned %s at commit %s@%s to %s", url, ref, commit, fullPath) info, err := os.Stat(fullPath) if err != nil { return "", err