Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 8f5300e

Browse files
committed
Changing package equality check to ignore size and only consider version
1 parent a5a8fc9 commit 8f5300e

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

utils/package_diff_utils.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ func multiVersionDiff(infoDiff []MultiVersionInfo, packageName string, map1, map
5252
diff1 = append(diff1, packInfo1)
5353
continue
5454
} else {
55-
if reflect.DeepEqual(packInfo1, packInfo2) {
55+
// If a package instance is installed in the same place in Image1 and Image2 with the same version,
56+
// then they are the same package and should not be included in the diff
57+
if packInfo1.Version == packInfo2.Version {
5658
delete(map2, path)
5759
} else {
5860
diff1 = append(diff1, packInfo1)
@@ -129,17 +131,21 @@ func diffMaps(map1, map2 interface{}) interface{} {
129131
packageEntry2 := map2Value.MapIndex(pack)
130132
if !packageEntry2.IsValid() {
131133
diff1.SetMapIndex(pack, packageEntry1)
132-
} else if !reflect.DeepEqual(packageEntry2.Interface(), packageEntry1.Interface()) {
134+
} else {
133135
if multiV {
134-
multiInfoDiff = multiVersionDiff(multiInfoDiff, pack.String(),
135-
packageEntry1.Interface().(map[string]PackageInfo), packageEntry2.Interface().(map[string]PackageInfo))
136+
if !reflect.DeepEqual(packageEntry2.Interface(), packageEntry1.Interface()) {
137+
multiInfoDiff = multiVersionDiff(multiInfoDiff, pack.String(),
138+
packageEntry1.Interface().(map[string]PackageInfo),
139+
packageEntry2.Interface().(map[string]PackageInfo))
140+
}
136141
} else {
137-
infoDiff = append(infoDiff, Info{pack.String(), packageEntry1.Interface().(PackageInfo),
138-
packageEntry2.Interface().(PackageInfo)})
142+
packageInfo1 := packageEntry1.Interface().(PackageInfo)
143+
packageInfo2 := packageEntry2.Interface().(PackageInfo)
144+
if packageInfo2.Version != packageInfo2.Version {
145+
infoDiff = append(infoDiff, Info{pack.String(), packageInfo1, packageInfo2})
146+
}
139147
}
140148
map2Value.SetMapIndex(pack, reflect.Value{})
141-
} else {
142-
map2Value.SetMapIndex(pack, reflect.Value{})
143149
}
144150
}
145151
for _, key2 := range map2Value.MapKeys() {

0 commit comments

Comments
 (0)