Repository navigation
Conversation
The example under "Generate a patch file in a custom directory for changes made to jquery" lacked --commit. Without --commit, bun patch prepares the folder again and does not read --patches-dir. Run as printed, the example wrote no patch file and replaced the edited folder with a fresh copy of the package. completions/bun-cli.json holds a copy of the example and gets the same edit.
|
Status: ready for a maintainer. The diff is green. CI is red only on macOS lanes, for reasons outside this diff. Reproduction, on 1.4.3-canary.1 (367d939) and on debug builds of main (116dd64, d7562f2, d0831bc):
The command exits 0, writes no patch file, and the edit is gone. With CI on 49b7dcb (build 128027):
No further push is planned for these failures. |
|
Updated 3:00 AM PT - Oct 18th, 2026
❌ @robobun, your commit 49b7dcb has 4 failures in
CapacityLimitExceededThis account has reached its capacity limit. Reach out to your account team for assistance.4a333035-8caa-41d7-b1bc-81802d33b172🧪 To try this PR locally: bunx bun-pr 45417That installs a local version of the PR into your bun-45417 --bun |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughThe Changesbun patch help examples
Suggested reviewers: Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to
|
…h-help-example-commit
The block "the examples in 'bun patch --help'" checked only that the patch file contains the added line. It now compares the whole file, for the default directory and for the custom directory.
There was a problem hiding this comment.
LGTM — a one-token help-text fix mirrored into the generated completions, and the follow-up push addresses the earlier note by asserting the exact patch contents.
What was reviewed:
- The
bun patch --helpexample andcompletions/bun-cli.jsonnow carry the identical--commit --patches-dir 'my-patches'line; thebun patch-commit --patches-direxample is unchanged and correct since that subcommand always commits. - The new test drives both "Generate a patch file" examples straight from the printed help output, so the
my-patchescase fails on the old text;existsSyncis not load-bearing because the patch file is also read and matched against an inline snapshot. installedProject,bunOk, andpatchedare existing helpers in the same file, so the test inherits the local-registry setup and stdout/stderr/exit assertions.
Extended reasoning...
The diff changes one example line in the bun patch --help string in src/install/PackageManager/CommandLineArguments.rs, the same line in the generated completions/bun-cli.json, and adds a concurrent test.each block in test/cli/install/bun-patch.test.ts that runs the printed examples against the local test registry. No code paths change and no security-sensitive surface is touched. The bug hunt ran dry, no CODEOWNERS entry covers the changed files, and the only prior inline feedback (a toContain assertion on the patch file) was replaced by an exact inline snapshot in the latest push, so nothing remains outstanding.
…h-help-example-commit
`bun patch --patches-dir <dir> <pkg>` took the flag, ignored it, and ran the prepare step. The prepare step replaces the folder of the package, so an edit that was not committed was gone, with exit code 0. The flag is now an error when `--commit` is absent. `CommandLineArguments::parse` prints `--patches-dir only applies to bun patch --commit` and exits 1 before it reads the project. `bun patch --commit --patches-dir` and `bun patch-commit --patches-dir` do not change. The custom directory example of `bun patch --help` gets `--commit`, and `completions/bun-cli.json` gets the same edit. Both lines are the same as in #45417.
Problem
bun patch --helpisbun patch --patches-dir 'my-patches' 'node_modules/jquery'. Its description is "Generate a patch file in a custom directory for changes made to jquery". Run as printed on an edited folder, it exits 0, writes no patch file, and the edit is gone.--commit. Without--commit,bun patchputs a fresh copy of the package in the folder and never reads--patches-dir(src/install/PackageManager/CommandLineArguments.rs:1626).Fix
bun patch --commit --patches-dir 'my-patches' 'node_modules/jquery'(CommandLineArguments.rs:989).completions/bun-cli.jsonholds a copy and gets the same edit.docs/pm/cli/patch.mdx:61already shows the flag with--commit.test/cli/install/bun-patch.test.tsruns both "Generate a patch file" examples as printed and compares the patch text. The custom directory example fails on the unfixed build. The file passes with the fix.Background
bun patch <pkg>prepares a package for editing: it replacesnode_modules/<pkg>with a fresh copy.bun patch --commit <folder>writes the patch file and records it inpatchedDependencies.misctools/generate-cli-completions.tsgeneratescompletions/bun-cli.jsonfrom the--helpoutput.--patches-dirwithout--commit, and a warning beforebun patchreplaces an edited folder. Both change the command and need a maintainer decision.Downsides
--patches-dirwithout--commitstill loses the edit, with exit 0 and no message.Notes
Reproduction, on 1.4.3-canary.1 (367d939) and on debug builds of main (116dd64, d7562f2 and d0831bc):
jquery.bun patch jquery.node_modules/jquery/index.js.bun patch --patches-dir 'my-patches' 'node_modules/jquery'.Result: exit 0, no
my-patchesdirectory, nopatchedDependenciesinpackage.json, andindex.jshas its original content.The test uses
"jquery": "npm:no-deps@1.0.0"so that the examples run unchanged against the local test registry.Test run with the fix, debug build with ASAN on Linux x64, main merged in at d0831bc: 220 pass, 5 skip (Windows only), 0 fail.
The test first checked only that the patch file contains the added line. After review it compares the whole patch text.
git grep my-patchesfinds one more example, inbun patch-commit --help. That example is correct:bun patch-commitalways commits.A full regeneration of
completions/bun-cli.jsonwith a debug build of 116dd64 changes 4,399 lines. This PR changes only the example line. The generator emits the same line for the new help text.The example has had this form since #20117.
no test proof · iteration 0 · platform-specific test(s) that do not run on this machine, deferring to CI, which covers all platforms: test/cli/install/bun-patch.test.ts