Skip to content

Remove source-only files when resetting inter-branch merge paths - #17740

Merged
akoeplinger merged 1 commit into
dotnet:mainfrom
akoeplinger:fix/inter-branch-reset-overlay
Oct 29, 2026
Merged

akoeplinger merged 1 commit into
dotnet:mainfrom
akoeplinger:fix/inter-branch-reset-overlay

Conversation

@akoeplinger

@akoeplinger akoeplinger commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

ResetFilesToTargetBranch uses git checkout in its default overlay mode. This restores target-branch files but does not remove files introduced only on the source branch, so reset paths can still differ from the target.

Use git checkout --no-overlay to remove those files too. This fixes the issue observed in dotnet/sourcelink#1787, where eng/common/run-helix-job-monitor.sh survived the eng/common/* reset.

Validation

Invoked the actual PowerShell helper functions, extracted via the PowerShell AST, against an isolated temporary Git repository. The unchanged script fails the source-only-file regression; the fixed script passes checks for:

  • Restoring modified and target-only files.
  • Removing source-only files, including nested files and an exact path absent from the target.
  • Preserving unrelated source changes.
  • Leaving no changes or additional commits on repeated resets or unmatched patterns.

PowerShell parsing and git diff --check passed. No .NET build was run; this change only affects the PowerShell workflow script.

Use non-overlay checkout so reset paths match the target branch, including deleting files introduced only on the source branch.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 50a9547c-92ce-4f2e-8ee3-664b5a00f3c0
Copilot AI balanced review requested due to automatic review settings October 29, 2026 12:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the workflow reset-path change.

No open issues 🎉

What changed in this PR

Updates the inter-branch merge workflow so reset paths match the target branch, including removal of files present only on the source branch.

Changes:

  • Adds --no-overlay to git checkout in ResetFilesToTargetBranch.
  • Clarifies the comment to describe both restoring target files and removing source-only files.
File Description
.github/​workflows/​scripts/​inter-branch-merge.ps1 Removes source-only files when resetting matching paths to the target branch.

Review effort: Balanced

@akoeplinger
akoeplinger merged commit 94f7972 into dotnet:main Oct 29, 2026
2 of 6 checks passed
@akoeplinger
akoeplinger deleted the fix/inter-branch-reset-overlay branch October 29, 2026 17:25
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 31, 2026
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.

3 participants