@@ -455,26 +455,8 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
455
455
return sreconcile .ResultEmpty , e
456
456
}
457
457
458
- repositoryURL := obj .Spec .URL
459
- // managed GIT transport only affects the libgit2 implementation
460
- if managed .Enabled () && obj .Spec .GitImplementation == sourcev1 .LibGit2Implementation {
461
- // We set the TransportAuthID of this set of authentication options here by constructing
462
- // a unique ID that won't clash in a multi tenant environment. This unique ID is used by
463
- // libgit2 managed transports. This enables us to bypass the inbuilt credentials callback in
464
- // libgit2, which is inflexible and unstable.
465
- if strings .HasPrefix (repositoryURL , "http" ) {
466
- authOpts .TransportAuthID = fmt .Sprintf ("http://%s/%s/%d" , obj .Name , obj .UID , obj .Generation )
467
- }
468
- if strings .HasPrefix (repositoryURL , "ssh" ) {
469
- authOpts .TransportAuthID = fmt .Sprintf ("ssh://%s/%s/%d" , obj .Name , obj .UID , obj .Generation )
470
- }
471
- }
472
-
473
458
// Fetch the included artifact metadata.
474
459
artifacts , err := r .fetchIncludes (ctx , obj )
475
- if err != nil {
476
- return sreconcile .ResultEmpty , err
477
- }
478
460
479
461
// Observe if the artifacts still match the previous included ones
480
462
if artifacts .Diff (obj .Status .IncludedArtifacts ) {
@@ -491,7 +473,27 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
491
473
optimizedClone = true
492
474
}
493
475
494
- c , err := r .gitCheckout (ctx , obj , repositoryURL , authOpts , dir , optimizedClone )
476
+ // managed GIT transport only affects the libgit2 implementation
477
+ if managed .Enabled () && obj .Spec .GitImplementation == sourcev1 .LibGit2Implementation {
478
+ // We set the TransportAuthID of this set of authentication options here by constructing
479
+ // a unique ID that won't clash in a multi tenant environment. This unique ID is used by
480
+ // libgit2 managed transports. This enables us to bypass the inbuilt credentials callback in
481
+ // libgit2, which is inflexible and unstable.
482
+ if strings .HasPrefix (obj .Spec .URL , "http" ) {
483
+ authOpts .TransportAuthID = fmt .Sprintf ("http://%s/%s/%d" , obj .Name , obj .UID , obj .Generation )
484
+ } else if strings .HasPrefix (obj .Spec .URL , "ssh" ) {
485
+ authOpts .TransportAuthID = fmt .Sprintf ("ssh://%s/%s/%d" , obj .Name , obj .UID , obj .Generation )
486
+ } else {
487
+ e := & serror.Stalling {
488
+ Err : fmt .Errorf ("git repository URL has invalid transport type: '%s'" , obj .Spec .URL ),
489
+ Reason : sourcev1 .GitOperationFailedReason ,
490
+ }
491
+ conditions .MarkTrue (obj , sourcev1 .FetchFailedCondition , e .Reason , e .Err .Error ())
492
+ return sreconcile .ResultEmpty , e
493
+ }
494
+ }
495
+
496
+ c , err := r .gitCheckout (ctx , obj , obj .Spec .URL , authOpts , dir , optimizedClone )
495
497
if err != nil {
496
498
e := serror .NewGeneric (
497
499
fmt .Errorf ("failed to checkout and determine revision: %w" , err ),
@@ -530,7 +532,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context,
530
532
531
533
// If we can't skip the reconciliation, checkout again without any
532
534
// optimization.
533
- c , err := r .gitCheckout (ctx , obj , repositoryURL , authOpts , dir , false )
535
+ c , err := r .gitCheckout (ctx , obj , obj . Spec . URL , authOpts , dir , false )
534
536
if err != nil {
535
537
e := serror .NewGeneric (
536
538
fmt .Errorf ("failed to checkout and determine revision: %w" , err ),
0 commit comments