diff --git a/common/vcs/git.go b/common/vcs/git.go index 4e8fb4240..c2c6402f7 100644 --- a/common/vcs/git.go +++ b/common/vcs/git.go @@ -257,11 +257,15 @@ func (gvcsrepo *GitVCSRepo) Clone(cloneOptions VCSCloneOptions) (string, error) } gvcsrepo.GitRepository, err = git.Clone(limitStorer, repoDirWt, &cloneOpts) if err != nil { - logrus.Debugf("failed to clone the given branch '%s' . Will clone the entire repo and try again.", gvcsrepo.Branch) + logrus.Warningf("failed to clone the given branch '%s': %v . Will clone the entire repo and try again.", gvcsrepo.Branch, err) cloneOpts := git.CloneOptions{ URL: gvcsrepo.URL, Depth: commitDepth, } + repoName := gvcsrepo.GitRepoPath[strings.LastIndex(gvcsrepo.GitRepoPath, "/")+1:] + deletePath := repoPath + "/" + repoName + logrus.Infof("Removing previous cloned repository folder: %q", deletePath) + os.RemoveAll(deletePath) gvcsrepo.GitRepository, err = git.Clone(limitStorer, repoDirWt, &cloneOpts) if err != nil { return "", fmt.Errorf("failed to perform clone operation using git. Error: %w", err)