@@ -516,7 +516,7 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
516
516
}
517
517
518
518
// Observe if the artifacts still match the previous included ones
519
- if artifacts .Diff (obj .Status .IncludedArtifacts ) {
519
+ if artifacts .Diff (obj .Status .IncludedArtifacts , gitArtifactRevisionEqual ) {
520
520
message := fmt .Sprintf ("included artifacts differ from last observed includes" )
521
521
if obj .Status .IncludedArtifacts != nil {
522
522
conditions .MarkTrue (obj , sourcev1 .ArtifactOutdatedCondition , "IncludeChange" , message )
@@ -593,7 +593,8 @@ func (r *GitRepositoryReconciler) reconcileSource(ctx context.Context, sp *patch
593
593
}
594
594
595
595
// Mark observations about the revision on the object
596
- if ! obj .GetArtifact ().HasRevision (commit .String ()) {
596
+ if curArtifact := obj .Status .Artifact ; curArtifact == nil ||
597
+ git .TransformRevision (curArtifact .Revision ) != commit .String () {
597
598
message := fmt .Sprintf ("new upstream revision '%s'" , commit .String ())
598
599
if obj .GetArtifact () != nil {
599
600
conditions .MarkTrue (obj , sourcev1 .ArtifactOutdatedCondition , "NewRevision" , message )
@@ -626,20 +627,22 @@ func (r *GitRepositoryReconciler) reconcileArtifact(ctx context.Context, sp *pat
626
627
627
628
// Set the ArtifactInStorageCondition if there's no drift.
628
629
defer func () {
629
- if obj .GetArtifact ().HasRevision (artifact .Revision ) &&
630
- ! includes .Diff (obj .Status .IncludedArtifacts ) &&
630
+ if curArtifact := obj .GetArtifact (); curArtifact != nil &&
631
+ git .TransformRevision (curArtifact .Revision ) == artifact .Revision &&
632
+ ! includes .Diff (obj .Status .IncludedArtifacts , gitArtifactRevisionEqual ) &&
631
633
! gitContentConfigChanged (obj , includes ) {
632
634
conditions .Delete (obj , sourcev1 .ArtifactOutdatedCondition )
633
635
conditions .MarkTrue (obj , sourcev1 .ArtifactInStorageCondition , meta .SucceededReason ,
634
- "stored artifact for revision '%s'" , artifact .Revision )
636
+ "stored artifact for revision '%s'" , curArtifact .Revision )
635
637
}
636
638
}()
637
639
638
640
// The artifact is up-to-date
639
- if obj .GetArtifact ().HasRevision (artifact .Revision ) &&
640
- ! includes .Diff (obj .Status .IncludedArtifacts ) &&
641
+ if curArtifact := obj .GetArtifact (); curArtifact != nil &&
642
+ git .TransformRevision (curArtifact .Revision ) == artifact .Revision &&
643
+ ! includes .Diff (obj .Status .IncludedArtifacts , gitArtifactRevisionEqual ) &&
641
644
! gitContentConfigChanged (obj , includes ) {
642
- r .eventLogf (ctx , obj , eventv1 .EventTypeTrace , sourcev1 .ArtifactUpToDateReason , "artifact up-to-date with remote revision: '%s'" , artifact .Revision )
645
+ r .eventLogf (ctx , obj , eventv1 .EventTypeTrace , sourcev1 .ArtifactUpToDateReason , "artifact up-to-date with remote revision: '%s'" , curArtifact .Revision )
643
646
return sreconcile .ResultSuccess , nil
644
647
}
645
648
@@ -1024,7 +1027,7 @@ func gitContentConfigChanged(obj *sourcev1.GitRepository, includes *artifactSet)
1024
1027
}
1025
1028
1026
1029
// Check if the included repositories are still the same.
1027
- if observedInclArtifact .Revision != currentIncl .Revision {
1030
+ if git . TransformRevision ( observedInclArtifact .Revision ) != git . TransformRevision ( currentIncl .Revision ) {
1028
1031
return true
1029
1032
}
1030
1033
if observedInclArtifact .Checksum != currentIncl .Checksum {
@@ -1047,3 +1050,10 @@ func gitRepositoryIncludeEqual(a, b sourcev1.GitRepositoryInclude) bool {
1047
1050
}
1048
1051
return true
1049
1052
}
1053
+
1054
+ func gitArtifactRevisionEqual (x , y * sourcev1.Artifact ) bool {
1055
+ if x == nil || y == nil {
1056
+ return false
1057
+ }
1058
+ return git .TransformRevision (x .Revision ) == git .TransformRevision (y .Revision )
1059
+ }
0 commit comments