Skip to content

[release/v7.4] Fix merge conflict checker for empty file lists and filter *.cs files#26387

Merged
TravisEz13 merged 1 commit intoPowerShell:release/v7.4from
TravisEz13:backport-26365
Nov 5, 2025
Merged

[release/v7.4] Fix merge conflict checker for empty file lists and filter *.cs files#26387
TravisEz13 merged 1 commit intoPowerShell:release/v7.4from
TravisEz13:backport-26365

Conversation

@TravisEz13
Copy link
Member

Backport of #26365 to release/v7.4

Triggered by @TravisEz13 on behalf of @copilot

Original CL Label: CL-Test

/cc @PowerShell/powershell-maintainers

Impact

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

This backport fixes the merge conflict checker script in CI to properly handle empty file lists and filter C# files. The original PR fixed issues where the script would fail when no files matched certain patterns, causing false positives in merge conflict detection.

Regression

  • Yes
  • No

This is a fix for tooling, not a regression fix.

Testing

The fix was tested in the original PR #26365 where it resolved issues with the merge conflict checker script failing on empty file lists. The changes ensure the script properly handles edge cases:

  • Empty arrays when no files match filters
  • Filtering out *.cs files from conflict checks
  • Proper handling of file list parameters

Risk

  • High
  • Medium
  • Low

This is a low-risk change as it only affects CI tooling scripts used for merge conflict detection. The changes improve the robustness of the checker by handling edge cases that previously caused false failures. The fix does not affect runtime PowerShell functionality or user-facing features.

@TravisEz13 TravisEz13 requested a review from a team as a code owner November 5, 2025 18:10
Copilot AI review requested due to automatic review settings November 5, 2025 18:10
@TravisEz13 TravisEz13 self-assigned this Nov 5, 2025
@TravisEz13 TravisEz13 added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Nov 5, 2025
Copy link
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 enhances the Test-MergeConflictMarker function to gracefully handle edge cases in merge conflict detection, specifically addressing scenarios where PRs have no files to check (e.g., delete-only PRs) and excluding C# files from conflict marker checking.

Key changes:

  • Modified the $File parameter to accept empty arrays by removing the Mandatory attribute and adding [AllowEmptyCollection()]
  • Added logic to filter out *.cs files from merge conflict checking with appropriate user feedback
  • Implemented a helper function Write-NoFilesOutput to standardize output when no files require checking
  • Updated tests to verify the new behavior for empty file arrays
  • Ensured the GitHub Action properly handles empty JSON arrays by wrapping ConvertFrom-Json output in @()

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
tools/ci.psm1 Enhanced Test-MergeConflictMarker to accept empty file arrays, filter out C# files, and handle edge cases with appropriate output generation
test/infrastructure/ciModule.Tests.ps1 Updated test to verify graceful handling of empty file arrays instead of expecting an error
.github/actions/infrastructure/merge-conflict-checker/action.yml Added array wrapping to handle empty JSON arrays from ConvertFrom-Json
.github/actions/infrastructure/merge-conflict-checker/README.md Documented the C# file filtering behavior and empty file list handling

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

@TravisEz13 TravisEz13 merged commit 61c4d47 into PowerShell:release/v7.4 Nov 5, 2025
44 of 45 checks passed
@TravisEz13 TravisEz13 deleted the backport-26365 branch November 5, 2025 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Test Indicates that a PR should be marked as a test change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants