Skip to content

Enhanced comparison - introduced an equalityClass#368

Merged
magerstam merged 14 commits intomainfrom
compare-improvement
Jan 29, 2026
Merged

Enhanced comparison - introduced an equalityClass#368
magerstam merged 14 commits intomainfrom
compare-improvement

Conversation

@magerstam
Copy link
Copy Markdown
Contributor

Merge Checklist

All boxes should be checked before merging the PR

  • The changes in the PR have been built and tested
  • Ready to merge

Description

  • Removed the Equal flag to introduce levels of equality with images
  • Semantically equal, Binary equal, Semantically equal (unverified)
  • Introduced an optional flag --hash-images (default: false) which performs a SHA256 digest calculation on the provided images. This can take up to 20 seconds for 4GB images so made this optional for quicker comparison between images
  • Updated unit tests
  • The new logic with the Equality class helps compare images that are identical from a semantical perspective, but has differences that mutates each time an image is built, despite that it was generated from the same template (such as partition table UUIDs, file system UUIDs, etc.)

(https://jira.devtools.intel.com/browse/ITEP-84987)

Any Newly Introduced Dependencies

How Has This Been Tested?

go-test

Copilot AI review requested due to automatic review settings January 28, 2026 02:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces the binary Equal flag with a multi-level EqualityClass system to better classify image comparisons. The new system distinguishes between binary identical, semantically identical, semantically identical (unverified), and different images, with support for classifying differences as volatile (e.g., UUIDs that change on each build) or meaningful (e.g., kernel changes).

Changes:

  • Introduced EqualityClass enum with four states: binary_identical, semantically_identical, semantically_identical_unverified, and different
  • Added optional --hash-images flag to compute SHA256 digests (disabled by default for performance)
  • Updated comparison logic to tally volatile vs. meaningful diffs with detailed reasoning

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
internal/image/imageinspect/renderer_text.go Updated text rendering to display equality class and hash information, added helper functions for rendering equality headers and reasons
internal/image/imageinspect/imageinspect_integration_test.go Updated test calls to pass hash parameter to inspector
internal/image/imageinspect/imageinspect_core_test.go Updated test calls to use new inspectCoreNoHash method
internal/image/imageinspect/imageinspect.go Added SHA256 computation support and hash parameter to inspector
internal/image/imageinspect/compare_test.go Updated test assertions to check Equality.Class instead of Equal boolean
internal/image/imageinspect/compare_efi.go Added kernel cmdline normalization to handle UUID variations
internal/image/imageinspect/compare.go Replaced Equal boolean with Equality struct, added diff tallying logic
internal/image/imageinspect/bootloader_efi.go Minor comment formatting updates
cmd/os-image-composer/inspect_cmd_test.go Updated test mocks to accept hash parameter
cmd/os-image-composer/inspect_cmd.go Updated inspector initialization to pass hash parameter
cmd/os-image-composer/compare_cmd_test.go Updated test mocks to accept hash parameter
cmd/os-image-composer/compare_cmd.go Added --hash-images flag and updated JSON output to use equality class

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/image/imageinspect/renderer_text.go Outdated
Comment thread internal/image/imageinspect/renderer_text.go Outdated
Comment thread internal/image/imageinspect/compare.go Outdated
Comment thread internal/image/imageinspect/compare.go Outdated
Comment thread cmd/os-image-composer/compare_cmd.go Outdated
@magerstam magerstam added the enhancement New feature or request label Jan 28, 2026
@magerstam magerstam changed the title added EqualityClass to compare results instead of Equal boolean Enhanced comparison - introduced an equalityClass Jan 28, 2026
Comment thread internal/image/imageinspect/compare.go
Comment thread internal/image/imageinspect/compare.go Outdated
Copy link
Copy Markdown
Contributor

@arodage arodage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments. Otherwise LGTM.

@magerstam magerstam merged commit 49aac31 into main Jan 29, 2026
21 checks passed
@magerstam magerstam deleted the compare-improvement branch January 29, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants