Skip to content

fix(cli): accept -g for approve-builds - #13329

Merged
zkochan merged 4 commits into
mainfrom
fix-13310
Jul 25, 2026
Merged

zkochan merged 4 commits into
mainfrom
fix-13310

Conversation

@zkochan

@zkochan zkochan commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Summary

approve-builds declared --global without the -g short form its ten peers all carry, so the short spelling failed in the argument parser instead of reaching pnpm's own error:

$ pnpm approve-builds -g
# before
error: unexpected argument '-g' found

# after, and the TypeScript CLI v11.17.0
Error: ERR_PNPM_APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL

pnpm accepts -g wherever it accepts --global. approve-builds was the only command out of eleven that did not.

Test

The --workspace-root conflict table now runs over both spellings, which is the property that was actually missing. That table used the long form throughout precisely because this command rejected the short one — so the gap it had surfaced was never asserted. Dropping the short form again fails it, naming both the subcommand and the spelling:

["approve-builds"] should parse with -w -g: error: unexpected argument '-g' found

Verified against v11.17.0: both -g and --global now produce ERR_PNPM_APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL on both stacks.

TypeScript CLI: no change needed — it is the reference.

Closes #13310

Squash Commit Body

`approve-builds` declared `--global` without the `-g` short form its ten
peers all carry, so `pnpm approve-builds -g` died in the argument parser
instead of reaching pnpm's own
ERR_PNPM_APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL. pnpm accepts `-g`
wherever it accepts `--global`.

The `--workspace-root` conflict table now runs over both spellings, which
is the property that was missing: it used the long form throughout
precisely because this one command rejected the short one, so the gap it
had surfaced went unasserted. Dropping the short form again fails the
table, naming the subcommand and the spelling.

Closes pnpm/pnpm#13310

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pnpm/ port, or the description notes what still needs porting.
    Rust-only: the TypeScript CLI is the reference behavior being matched.
  • Added a changeset (pnpm changeset) if this PR changes any published
    package. Keep it short and written for pnpm users — it becomes a release note.
  • Added or updated tests.
    The existing --global conflict table, extended to both spellings.

Written by an agent (Claude Code, claude-opus-5).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes

    • Restored proper handling of the -g shorthand for pnpm approve-builds.
    • The command now consistently reports that global packages aren’t supported for both --global and -g.
    • Improved validation for conflicts between the workspace-root redirect and global options, covering both --global and -g.
  • Tests

    • Expanded CLI and integration tests to cover both --global and -g spellings.

`approve-builds` declared `--global` without the `-g` short form its ten
peers all carry, so `pnpm approve-builds -g` died in the argument parser
instead of reaching pnpm's own
ERR_PNPM_APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL. pnpm accepts `-g`
wherever it accepts `--global`.

The `--workspace-root` conflict table now runs over both spellings, which
is the property that was missing: it used the long form throughout
precisely because this one command rejected the short one, so the gap it
had surfaced went unasserted. Dropping the short form again fails the
table, naming the subcommand and the spelling.

Closes #13310

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 25, 2026 11:36

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1c80a0ef-8ad4-44de-a8f9-370c7b9d0b8a

📥 Commits

Reviewing files that changed from the base of the PR and between 6d4d55d and 3fb9472.

📒 Files selected for processing (2)
  • pnpm/crates/cli/src/cli_args/tests.rs
  • pnpm/crates/cli/tests/approve_builds.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • pnpm/crates/cli/tests/approve_builds.rs
  • pnpm/crates/cli/src/cli_args/tests.rs

📝 Walkthrough

Walkthrough

approve-builds now accepts -g alongside --global. Conflict and rejection tests cover both spellings, and a changeset documents the resulting error behavior for global packages.

Changes

Approve builds global flag

Layer / File(s) Summary
Add approve-builds short global flag
pnpm/crates/cli/src/cli_args/approve_builds.rs
The global argument accepts both -g and --global.
Validate both global flag spellings
pnpm/crates/cli/src/cli_args/tests.rs, pnpm/crates/cli/tests/approve_builds.rs, .changeset/pacquet-approve-builds-short-global.md
Workspace-root conflict and approve-builds rejection tests cover both flag forms, and the changeset documents the behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Add the -g short form to approve-builds’s --global option [#13310] ✅
Ensure -g reaches pnpm’s global-package rejection instead of failing during argument parsing [#13310] ✅
Ensure global/workspace-root conflict coverage includes the short form [#13310] ✅

Possibly related PRs

  • pnpm/pnpm#13281: Adds related global/workspace-root conflict handling and intersects with the updated shared test.
  • pnpm/pnpm#13294: Introduces related workspace-root handling for global mode.

Suggested labels: product: pacquet

Suggested reviewers: copilot

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-13310

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Fix approve-builds to accept -g short flag for --global

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Add missing -g short flag to approve-builds global option.
• Extend workspace-root conflict coverage to assert both --global and -g.
• Add changeset entry documenting restored pnpm approve-builds -g behavior.
Diagram

graph TD
  A["User runs: pnpm approve-builds -g"] --> B["clap arg parser"] --> C["ApproveBuildsArgs (global flag)"] --> D["CliArgs.apply_workspace_root()"] --> E["WorkspaceRootError::GlobalConflict"]
  T["cli_args/tests.rs"] --> B
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Centralize global flag definition
  • ➕ Prevents per-subcommand drift (missing -g, help text inconsistencies)
  • ➕ Makes it easier to enforce uniform CLI UX across commands
  • ➖ Requires refactoring multiple subcommand arg structs
  • ➖ May be awkward if some commands intentionally diverge
2. Add a meta-test to enforce -g wherever --global exists
  • ➕ Catches future regressions without relying on individual conflict-table coverage
  • ➕ Keeps production code changes minimal
  • ➖ Requires introspecting clap metadata or maintaining a canonical list
  • ➖ Test can become brittle if CLI intentionally varies

Recommendation: The current fix (declare #[clap(short = &#x27;g&#x27;, long)] for approve-builds) is the most direct, least risky way to restore expected pnpm parity. Consider a follow-up to centralize the global flag (or add a small meta-test) to prevent future subcommands from accidentally omitting -g again.

Files changed (3) +25 / -17

Bug fix (1) +1 / -1
approve_builds.rsAdd '-g' short flag to approve-builds '--global' option +1/-1

Add '-g' short flag to approve-builds '--global' option

• Updates the clap attribute on 'ApproveBuildsArgs.global' to declare both the '--global' long form and the '-g' short form, matching pnpm conventions and other subcommands.

pnpm/crates/cli/src/cli_args/approve_builds.rs

Tests (1) +19 / -16
tests.rsTest workspace-root conflicts for both '--global' and '-g' +19/-16

Test workspace-root conflicts for both '--global' and '-g'

• Extends the workspace-root vs global conflict table to iterate over both spellings ('--global' and '-g'). This ensures subcommands missing the short form fail tests rather than failing earlier in clap parsing.

pnpm/crates/cli/src/cli_args/tests.rs

Documentation (1) +5 / -0
pacquet-approve-builds-short-global.mdAdd changeset documenting restored 'approve-builds -g' support +5/-0

Add changeset documenting restored 'approve-builds -g' support

• Adds a patch changeset for the pacquet package noting that 'pnpm approve-builds -g' is accepted again and now reaches pnpm's own unsupported-global error instead of failing in argument parsing.

.changeset/pacquet-approve-builds-short-global.md

@greptile-apps

greptile-apps Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Reviews (4): Last reviewed commit: "test(cli): assert the approve-builds --g..." | Re-trigger Greptile

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/cli/src/cli_args/tests.rs`:
- Around line 661-679: The existing loop in the CLI argument tests only
validates the -w conflict path and does not directly verify approve-builds
global-option behavior. Add a focused test for approve-builds using both -g and
--global that asserts each produces the same canonical
ERR_PNPM_APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL code and message, while
retaining the existing GLOBAL_SUBCOMMAND_ARGV conflict coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 15d19f8f-26cd-4955-bda6-d4a31698537d

📥 Commits

Reviewing files that changed from the base of the PR and between 875073e and 18415d2.

📒 Files selected for processing (3)
  • .changeset/pacquet-approve-builds-short-global.md
  • pnpm/crates/cli/src/cli_args/approve_builds.rs
  • pnpm/crates/cli/src/cli_args/tests.rs

Comment thread pnpm/crates/cli/src/cli_args/tests.rs Resolved
@qodo-code-review

qodo-code-review Bot commented Jul 25, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (2) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Historical used to doc comment 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The newly added test doc comment references prior behavior using historical phrasing (used to),
which is disallowed because comments must describe current behavior and intent. Keeping historical
notes inline increases maintenance risk when the code changes again.
Code

pnpm/crates/cli/tests/approve_builds.rs[R348-350]

+/// Both spellings reach the same rejection. `-g` used to stop in the
+/// argument parser instead (pnpm/pnpm#13310), which the long form alone
+/// could not have caught.
Relevance

⭐⭐⭐ High

Similar “used to/Before the fix” historical comment phrasing was previously changed when flagged in
CLI tests.

PR-#13246
PR-#13138
PR-#13117

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 forbids historical/temporal phrasing in comments. The added doc comment
explicitly says `-g` "used to" stop in the argument parser, which is historical context rather
than current behavior documentation.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/cli/tests/approve_builds.rs[348-350]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A new doc comment uses historical phrasing (`used to`) to describe past behavior. Comments must describe current behavior/intent rather than historical implementations.

## Issue Context
This comment is attached to `approve_builds_global_is_rejected()` and should explain the current contract being tested (that both `--global` and `-g` reach the same rejection path) without narrating what happened previously.

## Fix Focus Areas
- pnpm/crates/cli/tests/approve_builds.rs[348-350]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Informational

2. Noisy dbg! in test ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
workspace_root_conflicts_with_global_for_every_subcommand unconditionally calls dbg! inside a
loop, so it prints/allocates debug output for every iteration; with the new --global/-g loop it
now runs twice as often. This adds avoidable CI log noise (visible under --nocapture or on
failures) and minor overhead.
Code

pnpm/crates/cli/src/cli_args/tests.rs[R664-678]

+    for global in ["--global", "-g"] {
+        for subcommand in GLOBAL_SUBCOMMAND_ARGV {
+            let argv = std::iter::once("pacquet")
+                .chain(subcommand.iter().copied())
+                .chain(["-w", global, "-C"])
+                .chain([root.path().to_str().expect("utf-8 tmp dir")]);
+            let mut args = CliArgs::try_parse_from(argv).unwrap_or_else(|error| {
+                panic!("{subcommand:?} should parse with -w {global}: {error}");
+            });
+            let error = args
+                .apply_workspace_root()
+                .expect_err(&format!("{subcommand:?} must reject -w with {global}"));
+
+            dbg!(subcommand, global, &error);
+            assert!(matches!(error, WorkspaceRootError::GlobalConflict), "{subcommand:?} {global}");
Relevance

⭐⭐ Medium

Repo often accepts adding debug/log context in tests; unclear they’ll remove unconditional dbg!
here.

PR-#13177
PR-#13127

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The updated test loop runs for both --global and -g, and still calls dbg! unconditionally
before asserting the error type, meaning debug output/formatting happens on every passing iteration.

pnpm/crates/cli/src/cli_args/tests.rs[657-679]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`dbg!(subcommand, global, &error);` runs unconditionally in a passing test loop. With the new `--global`/`-g` matrix it executes 24 times per run, creating avoidable stderr output/log noise (often captured, but still present under `--nocapture` and can clutter failure logs) and minor runtime overhead.

## Issue Context
The test already provides good failure context via the `panic!(...)` during parsing and can include the error value in the assertion message.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/tests.rs[664-679]

### Suggested change
Remove the `dbg!` entirely, or only print on failure. For example:
- Replace `dbg!(...)` + `assert!(matches!(...))` with a single assert that includes the error:
 - `assert!(matches!(error, WorkspaceRootError::GlobalConflict), "{subcommand:?} {global}: {error:?}");`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset front-matter lists only pacquet and omits pnpm, which violates the requirement
to explicitly declare a pnpm bump in changesets. This can cause the release tooling to miss or
misclassify the change for pnpm.
Code

.changeset/pacquet-approve-builds-short-global.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

⭐ Low

Closely analogous “add pnpm entry” changeset suggestions were repeatedly rejected in recent PRs.

PR-#13304
PR-#13300
PR-#13297

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires that changeset front-matter includes an explicit pnpm entry with
a valid bump type. The added changeset front-matter contains only "pacquet": patch and does not
include pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-approve-builds-short-global.md[1-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset `.changeset/pacquet-approve-builds-short-global.md` is missing a `pnpm` entry in its front-matter.

## Issue Context
PR Compliance ID 713436 requires changesets to explicitly declare the `pnpm` package and use a valid bump type.

## Fix Focus Areas
- .changeset/pacquet-approve-builds-short-global.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit 3fb9472

Results up to commit 18415d2 ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Informational
1. Noisy dbg! in test ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
workspace_root_conflicts_with_global_for_every_subcommand unconditionally calls dbg! inside a
loop, so it prints/allocates debug output for every iteration; with the new --global/-g loop it
now runs twice as often. This adds avoidable CI log noise (visible under --nocapture or on
failures) and minor overhead.
Code

pnpm/crates/cli/src/cli_args/tests.rs[R664-678]

+    for global in ["--global", "-g"] {
+        for subcommand in GLOBAL_SUBCOMMAND_ARGV {
+            let argv = std::iter::once("pacquet")
+                .chain(subcommand.iter().copied())
+                .chain(["-w", global, "-C"])
+                .chain([root.path().to_str().expect("utf-8 tmp dir")]);
+            let mut args = CliArgs::try_parse_from(argv).unwrap_or_else(|error| {
+                panic!("{subcommand:?} should parse with -w {global}: {error}");
+            });
+            let error = args
+                .apply_workspace_root()
+                .expect_err(&format!("{subcommand:?} must reject -w with {global}"));
+
+            dbg!(subcommand, global, &error);
+            assert!(matches!(error, WorkspaceRootError::GlobalConflict), "{subcommand:?} {global}");
Relevance

⭐⭐ Medium

Repo often accepts adding debug/log context in tests; unclear they’ll remove unconditional dbg!
here.

PR-#13177
PR-#13127

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The updated test loop runs for both --global and -g, and still calls dbg! unconditionally
before asserting the error type, meaning debug output/formatting happens on every passing iteration.

pnpm/crates/cli/src/cli_args/tests.rs[657-679]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`dbg!(subcommand, global, &error);` runs unconditionally in a passing test loop. With the new `--global`/`-g` matrix it executes 24 times per run, creating avoidable stderr output/log noise (often captured, but still present under `--nocapture` and can clutter failure logs) and minor runtime overhead.

## Issue Context
The test already provides good failure context via the `panic!(...)` during parsing and can include the error value in the assertion message.

## Fix Focus Areas
- pnpm/crates/cli/src/cli_args/tests.rs[664-679]

### Suggested change
Remove the `dbg!` entirely, or only print on failure. For example:
- Replace `dbg!(...)` + `assert!(matches!(...))` with a single assert that includes the error:
 - `assert!(matches!(error, WorkspaceRootError::GlobalConflict), "{subcommand:?} {global}: {error:?}");`

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Changeset missing pnpm entry 📘 Rule violation § Compliance
Description
The new changeset front-matter lists only pacquet and omits pnpm, which violates the requirement
to explicitly declare a pnpm bump in changesets. This can cause the release tooling to miss or
misclassify the change for pnpm.
Code

.changeset/pacquet-approve-builds-short-global.md[R1-3]

+---
+"pacquet": patch
+---
Relevance

⭐ Low

Closely analogous “add pnpm entry” changeset suggestions were repeatedly rejected in recent PRs.

PR-#13304
PR-#13300
PR-#13297

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 713436 requires that changeset front-matter includes an explicit pnpm entry with
a valid bump type. The added changeset front-matter contains only "pacquet": patch and does not
include pnpm.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-approve-builds-short-global.md[1-3]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The changeset `.changeset/pacquet-approve-builds-short-global.md` is missing a `pnpm` entry in its front-matter.

## Issue Context
PR Compliance ID 713436 requires changesets to explicitly declare the `pnpm` package and use a valid bump type.

## Fix Focus Areas
- .changeset/pacquet-approve-builds-short-global.md[1-3]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@github-actions

github-actions Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     11.1±0.05ms    33.8 MB/sec    1.08     11.9±0.05ms    31.4 MB/sec
packument/parse                1.01     37.2±0.05µs  1784.3 MB/sec    1.00     37.0±0.33µs  1794.1 MB/sec
tarball/download_dependency    1.00      2.2±0.07ms  1999.3 KB/sec    1.06      2.3±0.06ms  1895.0 KB/sec

@codecov-commenter

codecov-commenter commented Jul 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.03%. Comparing base (875073e) to head (3fb9472).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13329      +/-   ##
==========================================
- Coverage   87.05%   87.03%   -0.02%     
==========================================
  Files         532      533       +1     
  Lines       91601    91682      +81     
==========================================
+ Hits        79741    79795      +54     
- Misses      11860    11887      +27     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The `--workspace-root` conflict table proves `-g` parses, not that it
reaches the right error, so it would still pass if the flag later mapped
somewhere else. The end-to-end rejection test already asserted the error
code for `--global`; run it over both spellings instead of adding a
parallel one. Dropping the short form fails it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@zkochan

zkochan commented Jul 25, 2026

Copy link
Copy Markdown
Member Author

Fair — fixed in the latest commit.

You're right that the --workspace-root table only proves -g parses; it would still pass if the flag later mapped somewhere else and never produced ERR_PNPM_APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL.

Rather than add a parallel assertion, I ran the existing end-to-end rejection test over both spellings — approve_builds_global_is_rejected already asserted the canonical error code for --global, so it was the natural home:

for global in ["--global", "-g"] {
    let assert = pacquet(&workspace).with_args(["approve-builds", global]).assert().failure();
    assert!(stderr.contains("ERR_PNPM_APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL"), "{global} stderr: {stderr}");
}

Both layers of coverage are retained, as you asked: the conflict table still runs over both spellings for all twelve global-accepting subcommands, and this one pins the error itself. Verified both fail when the short form is removed again.

2222 tests pass, lint and dylint clean.


Written by an agent (Claude Code, claude-opus-5).

Copilot AI review requested due to automatic review settings July 25, 2026 11:48

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 6d4d55d

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
pnpm/crates/cli/tests/approve_builds.rs (1)

348-350: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use a regular rationale comment and remove implementation history.

These lines document a private test, not a public API contract, and narrate removed parser behavior. Keep only the invariant this test protects in a regular // comment.

Proposed fix
-/// Both spellings reach the same rejection. `-g` used to stop in the
-/// argument parser instead (pnpm/pnpm#13310), which the long form alone
-/// could not have caught.
+// Both spellings must reach the canonical unsupported-global rejection.

As per coding guidelines, rustdoc comments are for public API contracts and regular comments are for implementation rationale. As per path instructions, comments must not describe removed implementation history.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pnpm/crates/cli/tests/approve_builds.rs` around lines 348 - 350, Replace the
rustdoc comment above the relevant test in approve_builds.rs with a regular //
comment that states only the invariant: both short and long option spellings
reach the same rejection. Remove the references to the private test’s history,
prior parser behavior, and issue number.

Sources: Coding guidelines, Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pnpm/crates/cli/tests/approve_builds.rs`:
- Around line 359-362: Update the regression assertions in the approve-builds
test to validate both the ERR_PNPM_APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL code
and the canonical user-facing error message for each global-option spelling,
including -g and --global. Keep the existing stderr context while ensuring both
invocations assert the same expected message.

---

Nitpick comments:
In `@pnpm/crates/cli/tests/approve_builds.rs`:
- Around line 348-350: Replace the rustdoc comment above the relevant test in
approve_builds.rs with a regular // comment that states only the invariant: both
short and long option spellings reach the same rejection. Remove the references
to the private test’s history, prior parser behavior, and issue number.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 935d7697-5c41-4f6a-9f16-1bdf638181e9

📥 Commits

Reviewing files that changed from the base of the PR and between 18415d2 and 6d4d55d.

📒 Files selected for processing (1)
  • pnpm/crates/cli/tests/approve_builds.rs

Comment thread pnpm/crates/cli/tests/approve_builds.rs Resolved
Running the table over both spellings turned one `dbg!` into 24 lines of
output on a passing run. The failure diagnostic it provided now lives in
the assertion message, which prints only when the assertion actually
fails.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 25, 2026 11:54

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 1bf15b6

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

The code alone would not catch the two spellings drifting to different
user-facing text, which is the thing this PR is about. Assert the canonical
message for each as well.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings July 25, 2026 12:00

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 25, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 3fb9472

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan
zkochan merged commit cf8fdc4 into main Jul 25, 2026
35 checks passed
@zkochan
zkochan deleted the fix-13310 branch July 25, 2026 12:10
kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
`approve-builds` declared `--global` without the `-g` short form its ten
peers all carry, so `pnpm approve-builds -g` died in the argument parser
instead of reaching pnpm's own
ERR_PNPM_APPROVE_BUILDS_NOT_SUPPORTED_WITH_GLOBAL. pnpm accepts `-g`
wherever it accepts `--global`.

The `--workspace-root` conflict table now runs over both spellings, which
is the property that was missing: it used the long form throughout
precisely because this one command rejected the short one, so the gap it
had surfaced went unasserted. Dropping the short form again fails the
table, naming the subcommand and the spelling.

Closes pnpm#13310
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pacquet: approve-builds rejects the -g short form of --global

3 participants