Skip to content

Add patchcheck, check vendor patch#2211

Merged
dagood merged 4 commits intomicrosoft/mainfrom
dev/dagood/patchcheck
Mar 25, 2026
Merged

Add patchcheck, check vendor patch#2211
dagood merged 4 commits intomicrosoft/mainfrom
dev/dagood/patchcheck

Conversation

@dagood
Copy link
Member

@dagood dagood commented Mar 24, 2026

Add patchcheck util command. Wire it up with selftest so CI automatically runs it.

patchcheck runs deterministic tests on our patch files without involving submodule state. Currently just includes a rule for the vendoring patch based on what it looks like now. (It can always be easily adjusted later. We can also add more rules.)

Copilot review doesn't want to touch the vendoring patch, presumably because it's huge. But what we ask it to do there seems like it can be tooled, so instead, Copilot can write this tool.

Ran into a Git oddity similar to this: https://stackoverflow.com/q/42386491. Copilot floundered (reflecting a lack of docs), even just asking it questions.

Moved testutil/dependency_test.go‎ to internal/dependency_test.go because it doesn't make sense to put tests into testutil just because they're tests. Tests generally belong in the package they're testing. So, along with putting the patchcheck tests in the patchcheck package, remove the potentially misleading testutil package.

@dagood dagood requested a review from a team as a code owner March 24, 2026 19:06
Copilot AI review requested due to automatic review settings March 24, 2026 19:06
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

Adds a new _util “patchcheck” facility to validate repository patch files (especially the vendor patch) deterministically, without applying patches or relying on submodule state. This fits into the eng/_util tool suite and CI/selftest workflow by providing a repeatable check over patches/*.patch.

Changes:

  • Introduces an internal patchcheck package that inspects patch modifications via git apply --numstat and enforces vendor-patch path constraints.
  • Adds a patchcheck command under eng/_util/cmd to run the checks and report issues.
  • Adds new tests: one to fail the build if patch issues are found, and one to enforce minimal dependency rules for _util commands.

Reviewed changes

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

Show a summary per file
File Description
eng/_util/internal/patchcheck/vendoronly.go Implements vendor-patch-only path rules and vendor patch identification.
eng/_util/internal/patchcheck/patchcheck.go Core patch scanning logic (walk patches, parse numstat, report issues).
eng/_util/internal/patchcheck/patchcheck_test.go Runs patchcheck in tests and fails on any issues.
eng/_util/internal/dependency_test.go Adds enforcement that _util command packages keep dependencies minimal.
eng/_util/cmd/patchcheck/patchcheck.go Adds CLI entry point for running patch checks from eng/run.ps1.

dagood and others added 2 commits March 24, 2026 12:17
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@dagood dagood merged commit 68b26e0 into microsoft/main Mar 25, 2026
57 checks passed
@dagood dagood deleted the dev/dagood/patchcheck branch March 25, 2026 17:17
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.

4 participants