Skip to content

[client] handle order of check when checking order of files in isChecksEqual #4219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 24, 2025

Conversation

pascal-fischer
Copy link
Collaborator

Describe your changes

The order of checks was not considered, only the order of files within a check. This was causing false results and unnecessary meta updates.

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • Extended the README / documentation, if necessary

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

@Copilot Copilot AI review requested due to automatic review settings July 24, 2025 18:32
Copy link
Contributor

@Copilot 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 fixes a bug in the isChecksEqual function where the order of checks in the slice was not being considered, only the order of files within each check. This was causing false equality results and unnecessary metadata updates.

  • Refactored the isChecksEqual function to normalize check slices by sorting both files within checks and the checks themselves
  • Added comprehensive test cases to verify the fix handles different check orderings correctly

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
client/internal/engine.go Rewrote isChecksEqual function to properly handle order independence for both checks and files
client/internal/engine_test.go Added test cases to verify the fix works with different check and file orderings

sortedFiles := make([]string, len(check.Files))
copy(sortedFiles, check.Files)
sort.Strings(sortedFiles)
normalized[i] = strings.Join(sortedFiles, "|")
Copy link
Preview

Copilot AI Jul 24, 2025

Choose a reason for hiding this comment

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

Using "|" as a delimiter could be problematic if filenames contain this character. Consider using a delimiter that's guaranteed not to appear in filenames, such as "\x00" (null byte), or use a more robust serialization approach.

Suggested change
normalized[i] = strings.Join(sortedFiles, "|")
normalized[i] = strings.Join(sortedFiles, "\x00")

Copilot uses AI. Check for mistakes.

lixmal
lixmal previously approved these changes Jul 24, 2025
Copy link

@pascal-fischer pascal-fischer merged commit cb1e437 into main Jul 24, 2025
33 checks passed
@pascal-fischer pascal-fischer deleted the fix/checks-is-equal branch July 24, 2025 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants