@@ -257,11 +257,21 @@ func (gvcsrepo *GitVCSRepo) Clone(cloneOptions VCSCloneOptions) (string, error)
257
257
}
258
258
gvcsrepo .GitRepository , err = git .Clone (limitStorer , repoDirWt , & cloneOpts )
259
259
if err != nil {
260
- logrus .Debugf ("failed to clone the given branch '%s' . Will clone the entire repo and try again." , gvcsrepo .Branch )
260
+ logrus .Warningf ("failed to clone the given branch '%s': %v . Will clone the entire repo and try again." , gvcsrepo .Branch , err )
261
261
cloneOpts := git.CloneOptions {
262
262
URL : gvcsrepo .URL ,
263
263
Depth : commitDepth ,
264
264
}
265
+ logrus .Infof ("Removing previous cloned repository folder and recreating storer: %q" , repoPath )
266
+
267
+ if err := os .RemoveAll (repoPath ); err != nil {
268
+ return "" , fmt .Errorf ("failed to remove the files/directories at '%s' . error: %w" , repoPath , err )
269
+ }
270
+ repoDirWt = osfs .New (repoPath )
271
+ dotGitDir , _ = repoDirWt .Chroot (git .GitDirName )
272
+ fStorer := filesystem .NewStorage (dotGitDir , cache .NewObjectLRUDefault ())
273
+ limitStorer := Limit (fStorer , cloneOptions .MaxSize )
274
+
265
275
gvcsrepo .GitRepository , err = git .Clone (limitStorer , repoDirWt , & cloneOpts )
266
276
if err != nil {
267
277
return "" , fmt .Errorf ("failed to perform clone operation using git. Error: %w" , err )
@@ -273,7 +283,7 @@ func (gvcsrepo *GitVCSRepo) Clone(cloneOptions VCSCloneOptions) (string, error)
273
283
return "" , fmt .Errorf ("failed return a worktree for the repostiory. Error: %w" , err )
274
284
}
275
285
if err := w .Checkout (& git.CheckoutOptions {Create : false , Force : false , Branch : b }); err != nil {
276
- logrus .Debugf ("failed to checkout the branch '%s', creating it..." , b )
286
+ logrus .Warningf ("failed to checkout the branch '%s', creating it..." , b )
277
287
if err := w .Checkout (& git.CheckoutOptions {Create : true , Force : false , Branch : b }); err != nil {
278
288
return "" , fmt .Errorf ("failed checkout a new branch. Error : %+v" , err )
279
289
}
0 commit comments