Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: the bug of unexpected.git directory #758

Merged
merged 1 commit into from
Jan 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/scaffold/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ func IsTemplateURL(templateNamePathOrURL string) bool {
}

// retrieveURLTemplates retrieves the "template repository" at the specified URL.
func retrieveURLTemplates(rawurl string, online bool) (TemplateRepository, error) {
func retrieveURLTemplates(rawURL string, online bool) (TemplateRepository, error) {
if !online {
return TemplateRepository{}, fmt.Errorf("cannot use %s offline", rawurl)
return TemplateRepository{}, fmt.Errorf("cannot use %s offline", rawURL)
}

var err error
Expand All @@ -162,7 +162,7 @@ func retrieveURLTemplates(rawurl string, online bool) (TemplateRepository, error
}

var fullPath string
if fullPath, err = workspace.RetrieveGitFolder(rawurl, temp); err != nil {
if fullPath, err = workspace.RetrieveGitFolder(rawURL, temp); err != nil {
return TemplateRepository{}, fmt.Errorf("failed to retrieve git folder: %w", err)
}

Expand Down Expand Up @@ -201,6 +201,9 @@ func retrieveKusionTemplates(templateName string, online bool) (TemplateReposito
}

// Ensure the template directory exists.
if err = os.RemoveAll(templateDir); err != nil {
return TemplateRepository{}, err
}
if err = os.MkdirAll(templateDir, DefaultDirectoryPermission); err != nil {
return TemplateRepository{}, err
}
Expand All @@ -211,9 +214,6 @@ func retrieveKusionTemplates(templateName string, online bool) (TemplateReposito
branch := plumbing.NewBranchReferenceName(kusionTemplateBranch)
err = gitutil.GitCloneOrPull(repo, branch, templateDir, false /*shallow*/)
if err != nil {
if removeErr := os.RemoveAll(templateDir); removeErr != nil {
return TemplateRepository{}, removeErr
}
return TemplateRepository{}, fmt.Errorf("cloning templates failed. Please try again: %w", err)
}
}
Expand Down
Loading