Skip to content

feat(pacquet): support the changed-packages filter selector ([<since>]) - #12914

Merged
zkochan merged 5 commits into
mainfrom
pq-git-diff-filter
Jul 10, 2026
Merged

zkochan merged 5 commits into
mainfrom
pq-git-diff-filter

Conversation

@zkochan

@zkochan zkochan commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Ports git-diff project selection (getChangedProjects) from @pnpm/workspace.projects-filter to pacquet, so a --filter "...[<since>]" selector selects the workspace projects whose files changed since the given git ref instead of failing with pacquet_workspace_projects_filter::unsupported_diff_selector.

This fixes the ci:test-branch CI job, which currently fails on every PR because .github/scripts/run-ts-tests-chunk.mjs discovers affected packages with pn --filter=...[origin/main] -r list --depth=-1 --json and the pacquet-based @pnpm/exe rejects the selector (example failure: https://github.com/pnpm/pnpm/actions/runs/29056291664/job/86252459055).

What the port covers, mirroring the TypeScript implementation:

  • git diff --name-only <since> -- <workspace_dir> runs in the selector's {dir} part when present, else the workspace root; diff paths are resolved against the parent of the nearest .git directory, falling back to the nearest .git file (git worktrees).
  • Each changed file maps to its nearest enclosing workspace project. Files matching changedFilesIgnorePattern are ignored; projects whose changes all match testPattern are selected without their dependents. Patterns are matched with wax, the glob crate pacquet already uses where upstream uses micromatch/fast-glob.
  • A failing git diff surfaces git's stderr under pnpm's ERR_PNPM_FILTER_CHANGED error code with the same message text.
  • The testPattern / changedFilesIgnorePattern settings are read from pnpm-workspace.yaml and PNPM_CONFIG_* env vars, overridable by the new global --test-pattern / --changed-files-ignore-pattern flags, and excluded from the global config.yaml — matching the TypeScript config surface.

The feature itself already exists in the TypeScript CLI; this PR closes the parity gap on the pacquet side. Review of the port surfaced two bugs present in both stacks, which are fixed here in both (per the repo's parity rule):

  • git argument injection: --filter "[--output=<path>]" made git diff write its output to an arbitrary file and exit 0. Both stacks now pass --end-of-options, so git rejects option-like refs as bad revisions under ERR_PNPM_FILTER_CHANGED.
  • worktrees nested inside another repository's tree: the repo root was resolved by preferring a .git directory anywhere up the tree over the worktree's .git file, anchoring diff paths at the wrong root. Both stacks now use the nearest .git entry of either kind (TypeScript: find.up).

Verification against the failing job:

  • The exact failing invocation pn --filter=...[origin/main] -r list --depth=-1 --json now succeeds at this repository's root (a git worktree, so the .git-file path is exercised).
  • node .github/scripts/run-ts-tests-chunk.mjs --script ci:test-branch --chunk 1 --chunks 10 --dry-run with the patched binary on PATH as pn completes and selects test tasks from the changed packages (it previously exited 1 at the list step).
  • Parity check: the TypeScript CLI (freshly bundled pnpm11/pnpm/dist/pnpm.mjs) and the patched pacquet binary select the byte-identical project set for ...[origin/main] on this repo — also when --test-pattern or --changed-files-ignore-pattern is added.
  • All upstream tests around this feature are ported, and each was confirmed to fail when the implementation is deliberately broken:
    • the three workspace/projects-filter unit tests, from their known_failures stubs into filter::tests::changed_packages (basic selection including quoted non-ASCII paths, git-worktree layout, and the nonexistent-ref error);
    • the two pnpm/test/monorepo e2e tests: testPattern is respected by the test script (dependents of a test-only-changed project stay unselected on a recursive test run) and changedFilesIgnorePattern is respected (yaml-configured ignore patterns including brace alternation, plus the empty --changed-files-ignore-pattern= CLI override disabling them);
    • the two config/reader tests (respects testPattern / respects changedFilesIgnorePattern) as workspace-yaml config tests, plus their exclusion from the global config.yaml. The upstream .npmrc-is-ignored case has no pacquet counterpart because pacquet reads no settings from .npmrc, and the parse-cli-args single-value --test-pattern case is enforced by clap's declared arity.

Squash Commit Body

Port git-diff project selection from @pnpm/workspace.projects-filter to
pacquet, so a --filter "...[origin/main]" selector selects the workspace
projects whose files changed since the given git ref instead of failing
with unsupported_diff_selector. This unblocks the ci:test-branch job,
whose "pn --filter=...[origin/main] -r list --depth=-1 --json" discovery
step fails on every PR with the pacquet-based pnpm exe.

The port mirrors upstream getChangedProjects:

- "git diff --name-only <since> -- <workspace_dir>" runs in the
  selector's {dir} (else the workspace root); the repository root the
  diff paths are relative to is the parent of the nearest .git
  directory, falling back to the nearest .git file (worktrees).
- Each changed file maps to the nearest enclosing workspace project.
  Files matching changedFilesIgnorePattern are ignored entirely;
  projects whose changes all match testPattern are selected without
  their dependents. Both pattern sets are matched with wax, the glob
  crate pacquet already uses where upstream uses micromatch/fast-glob.
- A failing git diff surfaces git's stderr under pnpm's
  ERR_PNPM_FILTER_CHANGED error code.

FilterWorkspaceProjectsOptions / FilterProjectsOptions gain
workspace_dir, test_pattern, and changed_files_ignore_pattern, threaded
from Config by the recursive commands and deploy. The testPattern /
changedFilesIgnorePattern settings are read from pnpm-workspace.yaml
and PNPM_CONFIG_* env vars, overridable by the global --test-pattern /
--changed-files-ignore-pattern flags, and excluded from the global
config.yaml - all matching the TypeScript CLI.

All upstream tests around the feature are ported: the three
projects-filter unit tests (from their known_failures stubs into
filter::tests::changed_packages), the two monorepo e2e tests
(testPattern respected by the test script; changedFilesIgnorePattern
respected incl. the empty CLI override), and the config-reader tests
for both settings. The recursive run/exec integration tests now assert
the selector scopes execution to the changed project. Verified against the
TypeScript CLI on this repository: both stacks select the identical
project set for ...[origin/main], with and without the two pattern
flags.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    pacquet/ port, or the description notes what still needs porting.
  • 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.

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

Summary by CodeRabbit

  • New Features
    • Recursive commands now support changed-project selectors based on Git revisions.
    • Added --test-pattern and --changed-files-ignore-pattern options for controlling project selection.
    • Changed-file ignore patterns can now be configured or overridden from the command line.
  • Bug Fixes
    • Improved changed-project detection in Git worktrees and nested repositories.
    • Prevented option-like revision values from being misinterpreted as Git options.
    • Updated filtering behavior so only relevant changed projects are selected.

Copilot AI review requested due to automatic review settings July 10, 2026 15:20

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 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Changed-project filtering now supports additional pattern options through the native CLI, resolves git worktrees using the nearest .git entry, and protects diff revision arguments from option parsing. Tests cover recursive commands, ignored files, matching patterns, worktrees, and invalid revisions.

Changes

Configuration and CLI plumbing

Layer / File(s) Summary
Filter option propagation
pnpm/crates/cli/src/cli_args/cli_command.rs, dispatch.rs, deploy.rs, recursive.rs
Adds CLI and configuration handling for testPattern and changedFilesIgnorePattern, then passes both options through deployment and recursive project selection.

Changed-project resolution

Layer / File(s) Summary
Git diff and worktree handling
pnpm11/workspace/projects-filter/src/getChangedProjects.ts
Uses the nearest .git entry for repository resolution and inserts --end-of-options before the diff revision argument.

Command validation and release records

Layer / File(s) Summary
Changed-project integration coverage
pnpm11/workspace/projects-filter/test/index.ts, pnpm/crates/cli/tests/exec_recursive.rs, pnpm/crates/cli/tests/list.rs, pnpm/crates/cli/tests/run_recursive.rs
Tests worktree selection, option-like revisions, recursive exec and run, ignored-file patterns, and testPattern behavior.
Package release record
.changeset/changed-packages-filter-hardening.md
Records patch releases for the changed-packages filter packages.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant RecursiveSelection
  participant WorkspaceFilter
  participant Git
  CLI->>RecursiveSelection: provide filter and pattern options
  RecursiveSelection->>WorkspaceFilter: pass FilterWorkspaceProjectsOptions
  WorkspaceFilter->>Git: resolve diff revision and changed paths
  Git-->>WorkspaceFilter: changed files
  WorkspaceFilter-->>RecursiveSelection: selected projects
  RecursiveSelection-->>CLI: execute selected command
Loading

Possibly related PRs

  • pnpm/pnpm#12712: Both modify recursive workspace project selection and filter propagation.
  • pnpm/pnpm#12726: Both thread additional selection options through recursive filtering.

Suggested labels: product: pacquet, product: pnpm@11

Suggested reviewers: qodo-code-review, KSXGitHub

✨ 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 pq-git-diff-filter

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

feat(pacquet): support changed-packages filter selector ([&lt;since&gt;])

✨ Enhancement 🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Ports getChangedProjects git-diff project selection from @pnpm/workspace.projects-filter to
 pacquet's Rust filter engine.
• A --filter "...[]" selector now resolves to workspace projects whose files changed since a git
 ref, instead of erroring with unsupported_diff_selector.
• Adds testPattern / changedFilesIgnorePattern config (yaml, env vars, and new --test-pattern
 / --changed-files-ignore-pattern flags) threaded through Config into the filter options.
• Failing git diff invocations now surface stderr under pnpm's ERR_PNPM_FILTER_CHANGED error
 code, matching the TypeScript CLI.
• Ports the three upstream diff-selector tests out of known_failures stubs and updates recursive
 run/exec integration tests to exercise real changed-project selection.
Diagram

graph TD
    CLI["CLI --filter flag"] --> Config["Config (test_pattern, changed_files_ignore_pattern)"] --> FilterGraph["filter_graph / WalkState"]
    FilterGraph -->|diff selector| GetChanged["get_changed_projects"]
    GetChanged -->|spawns| Git[(git diff --name-only)]
    GetChanged -->|glob match| Wax[[wax glob crate]]
    FilterGraph --> Selected["Selected workspace projects"]
    subgraph Legend
      direction LR
      _svc([Service/Module]) ~~~ _db[(External Process)] ~~~ _ext[[Library]]
    end
Loading
High-Level Assessment

Faithfully porting upstream's getChangedProjects algorithm (directory-based nearest-project mapping, source/test change classification, dependents suppression) is the correct approach here since the goal is byte-identical behavior with the existing TypeScript CLI. Reusing wax (already a pacquet dependency) instead of introducing a new glob library for micromatch/fast-glob parity is the right tradeoff between fidelity and dependency footprint. No meaningfully different architecture was worth considering for this parity-focused port.

Files changed (17) +723 / -178

Enhancement (6) +348 / -59
cli_command.rsAdd --test-pattern and --changed-files-ignore-pattern CLI flags +14/-0

Add --test-pattern and --changed-files-ignore-pattern CLI flags

• Introduces two new global CLI flags that override the corresponding Config settings used by the changed-packages filter selector.

pacquet/crates/cli/src/cli_args/cli_command.rs

deploy.rsThread new filter options into deploy's project selection +3/-0

Thread new filter options into deploy's project selection

• Passes workspace_dir, test_pattern, and changed_files_ignore_pattern from Config into FilterWorkspaceProjectsOptions for deploy's select_project.

pacquet/crates/cli/src/cli_args/deploy.rs

dispatch.rsWire new pattern flags into Config during dispatch +11/-0

Wire new pattern flags into Config during dispatch

• Destructures the new CLI args and, when non-empty, overrides cfg.test_pattern and cfg.changed_files_ignore_pattern.

pacquet/crates/cli/src/cli_args/dispatch.rs

recursive.rsThread changed-packages options through recursive project selection +19/-13

Thread changed-packages options through recursive project selection

• Builds a shared FilterWorkspaceProjectsOptions carrying workspace_dir, test_pattern, and changed_files_ignore_pattern and passes it to filter_against/filter_workspace_projects instead of a hardcoded default.

pacquet/crates/cli/src/cli_args/recursive.rs

filter.rsImplement diff-selector evaluation in filter_graph +142/-46

Implement diff-selector evaluation in filter_graph

• Replaces the UnsupportedDiffSelector error with real handling: invokes get_changed_projects for diff selectors, refactors the walk logic into WalkState/WalkFlags, adds FilterChanged and InvalidPattern error variants, and extends FilterWorkspaceProjectsOptions/FilterProjectsOptions with workspace_dir/test_pattern/changed_files_ignore_pattern.

pacquet/crates/workspace-projects-filter/src/filter.rs

get_changed_projects.rsAdd get_changed_projects module implementing git-diff project selection +159/-0

Add get_changed_projects module implementing git-diff project selection

• New module that runs 'git diff --name-only' scoped to the workspace directory, maps changed files to nearest enclosing project via git-root resolution (handling worktrees), classifies each project's changes as source or test using wax glob patterns, and returns changed/test-only project lists.

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs

Tests (4) +330 / -106
exec_recursive.rsUpdate recursive exec test to assert changed-package selection +33/-16

Update recursive exec test to assert changed-package selection

• Replaces the previous unsupported-selector-must-fail test with one that sets up a real git repo and asserts exec runs only on the changed project.

pacquet/crates/cli/tests/exec_recursive.rs

run_recursive.rsUpdate recursive run test to assert changed-package selection +39/-16

Update recursive run test to assert changed-package selection

• Replaces the previous unsupported-selector-must-fail test with one that sets up a real git repo and asserts run scopes execution to the changed project only.

pacquet/crates/cli/tests/run_recursive.rs

tests.rsPopulate new Config fields in test fixture +2/-0

Populate new Config fields in test fixture

• Adds empty test_pattern and changed_files_ignore_pattern fields to the test Config constructor to satisfy the updated struct.

pacquet/crates/package-manager/src/install_package_from_registry/tests.rs

tests.rsPort changed-packages selector tests from known_failures +256/-74

Port changed-packages selector tests from known_failures

• Removes the stubbed known_failures module and adds a real changed_packages test module covering basic selection with non-ASCII paths, git-worktree layouts, and nonexistent-ref errors using real git repositories.

pacquet/crates/workspace-projects-filter/src/filter/tests.rs

Documentation (3) +16 / -13
pacquet-changed-packages-filter.mdAdd changeset for changed-packages filter feature +5/-0

Add changeset for changed-packages filter feature

• Documents the new native pnpm CLI support for the '[<since>]' changed-packages filter selector and its two new pattern flags as a patch release note.

.changeset/pacquet-changed-packages-filter.md

lib.rsRegister new get_changed_projects module and update doc comment +4/-3

Register new get_changed_projects module and update doc comment

• Adds the get_changed_projects module declaration and updates crate-level documentation to reflect that the changed-packages selector is now supported.

pacquet/crates/workspace-projects-filter/src/lib.rs

TEST_PORTING.mdUpdate test porting checklist for changed-packages selectors +7/-10

Update test porting checklist for changed-packages selectors

• Marks the three changed-packages selector tests as ported (rather than stubbed) and updates references to their new test module locations.

pacquet/plans/TEST_PORTING.md

Other (4) +29 / -0
env_overlay.rsRead TEST_PATTERN / CHANGED_FILES_IGNORE_PATTERN env overrides +2/-0

Read TEST_PATTERN / CHANGED_FILES_IGNORE_PATTERN env overrides

• Adds env-var overlay entries for the two new config fields, matching PNPM_CONFIG_* naming.

pacquet/crates/config/src/env_overlay.rs

lib.rsAdd test_pattern and changed_files_ignore_pattern to Config +14/-0

Add test_pattern and changed_files_ignore_pattern to Config

• Declares the two new Config fields with documentation describing their role in the changed-packages selector.

pacquet/crates/config/src/lib.rs

workspace_yaml.rsRead testPattern/changedFilesIgnorePattern from pnpm-workspace.yaml +11/-0

Read testPattern/changedFilesIgnorePattern from pnpm-workspace.yaml

• Adds the two optional fields to WorkspaceSettings, includes them in reset/merge logic, matching the TypeScript config surface.

pacquet/crates/config/src/workspace_yaml.rs

Cargo.tomlAdd wax and tempfile dependencies +2/-0

Add wax and tempfile dependencies

• Adds the wax glob crate as a runtime dependency and tempfile as a dev-dependency for the new git-diff tests.

pacquet/crates/workspace-projects-filter/Cargo.toml

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (4) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 18 rules

Grey Divider


Action required

1. Windows CI test early-return 📘 Rule violation ▣ Testability ⭐ New
Description
The newly added Jest tests return early on CI Windows without an issue reference or explicit
justification, effectively skipping coverage on that platform. This violates the requirement to
avoid introducing skipped/ignored tests without tracked rationale.
Code

pnpm11/workspace/projects-filter/test/index.ts[R594-597]

+test('select changed packages when operating under a git worktree nested inside the main repository', async () => {
+  if (isCI && isWindows()) {
+    return
+  }
Evidence
PR Compliance ID 713440 requires that tests are not newly skipped/ignored without an explicit issue
reference and justification. The added tests use an early return on CI Windows, which silently
skips execution on that platform.

Rule 713440: Investigate and resolve all failing tests before merge
pnpm11/workspace/projects-filter/test/index.ts[594-597]
pnpm11/workspace/projects-filter/test/index.ts[658-661]

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

## Issue description
New tests are conditionally skipped on CI Windows via `if (isCI && isWindows()) { return }` without a linked tracking issue or documented justification.

## Issue Context
The compliance rule requires that newly skipped/ignored tests include an explicit issue reference and rationale, or the tests should be made to pass on that platform.

## Fix Focus Areas
- pnpm11/workspace/projects-filter/test/index.ts[594-597]
- pnpm11/workspace/projects-filter/test/index.ts[658-661]

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


2. Unused import fails clippy ✗ Dismissed 🐞 Bug ≡ Correctness
Description
get_changed_projects.rs imports wax::Program but never uses it; CI runs `cargo clippy ... -D
warnings`, so this unused import will fail the build.
Code

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[10]

+use wax::{Glob, Program};
Evidence
The new file imports Program without any references in the module, which triggers an unused-import
warning. The Rust CI workflow runs clippy with -D warnings, turning that warning into a failure.

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[1-20]
.github/workflows/pacquet-ci.yml[236-243]

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 new module `get_changed_projects.rs` imports `wax::Program` but does not use it. The repo’s CI runs clippy with `-D warnings`, so this unused import becomes a hard error.

## Issue Context
This PR introduces `get_changed_projects.rs` and adds a `use wax::{Glob, Program};` import, but `Program` is unused.

## Fix Focus Areas
- pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[1-20]
- .github/workflows/pacquet-ci.yml[236-243]

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


3. trim_end() changes error message ✓ Resolved 📘 Rule violation ≡ Correctness
Description
The new git-diff error path trims git stderr before surfacing it, which can change the user-visible
message compared to pnpm's TypeScript implementation. This risks breaking expected error-message
equivalence.
Code

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[R93-97]

+        .map_err(|err| FilterError::FilterChanged { stderr: err.to_string() })?;
+    if !output.status.success() {
+        return Err(FilterError::FilterChanged {
+            stderr: String::from_utf8_lossy(&output.stderr).trim_end().to_string(),
+        });
Evidence
Pacquet applies trim_end() to output.stderr before formatting the error, while pnpm TypeScript
uses err.stderr directly in the error message template; this produces different user-visible
output.

Rule 713473: Align pacquet error codes and messages with pnpm
pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[88-98]
pnpm11/workspace/projects-filter/src/getChangedProjects.ts[61-76]

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

## Issue description
Pacquet trims `git diff` stderr (`trim_end()`), but pnpm TypeScript forwards stderr without trimming. This makes pacquet's error message diverge from pnpm for the same failure.

## Issue Context
The compliance rule requires pacquet error messages to align with pnpm, and the PR description claims parity for the changed-packages selector.

## Fix Focus Areas
- pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[88-98]
- pnpm11/workspace/projects-filter/src/getChangedProjects.ts[61-76]

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



Remediation recommended

4. Windows git tests may flake 🐞 Bug ☼ Reliability ⭐ New
Description
The newly added Rust tests for the worktree-nested case and the option-like diff ref run
unconditionally, but the upstream TypeScript suite skips these exact scenarios on Windows in CI.
Since this repo’s Rust CI runs just test-pacquet on windows-latest, these tests can fail/flap on
Windows runners even when the implementation is correct.
Code

pnpm/crates/workspace-projects-filter/src/filter/tests.rs[R638-671]

+    fn option_like_diff_ref_is_rejected_as_bad_revision() {
+        let workspace = TempDir::new().expect("create tempdir");
+        init_repo(workspace.path());
+        touch(&workspace.path().join("package-a").join("file.js"));
+        commit_all(workspace.path());
+        let graph = graph_of(&[&workspace.path().join("package-a")]);
+
+        let evil_output = workspace.path().join("evil.txt");
+        let error = filter_workspace_projects(
+            &graph,
+            &[diff_selector(&format!("--output={}", evil_output.to_string_lossy()))],
+            &FilterWorkspaceProjectsOptions {
+                workspace_dir: workspace.path().to_path_buf(),
+                ..Default::default()
+            },
+        )
+        .unwrap_err();
+
+        dbg!(&error);
+        assert!(matches!(error, FilterError::FilterChanged { .. }));
+        assert!(
+            error.to_string().contains("bad revision"),
+            "git must treat the option-like ref as a revision, got: {error}",
+        );
+        assert!(!evil_output.exists(), "the ref must not be honored as a git option");
+    }
+
+    /// A worktree checked out *inside* another repository's tree still
+    /// resolves diff paths against the worktree root: the nearest
+    /// `.git` entry is the worktree's `.git` file, even though an
+    /// ancestor has a `.git` directory.
+    #[test]
+    fn select_changed_packages_under_git_worktree_nested_in_main_repo() {
+        let main_repo = TempDir::new().expect("create tempdir");
Evidence
Rust CI includes a windows-latest test leg, and the upstream suite explicitly disables these two
scenarios on Windows CI; the Rust ports currently have no analogous guard around the same scenarios.

.github/workflows/pacquet-ci.yml[89-99]
pnpm11/workspace/projects-filter/test/index.ts[594-661]
pnpm/crates/workspace-projects-filter/src/filter/tests.rs[634-701]

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

### Issue description
Two ported tests that shell out to `git` (`git worktree add` and the option-like diff ref case) run unconditionally in Rust, but upstream skips them on Windows CI. This repo’s Rust CI runs on `windows-latest`, so these tests risk platform-specific failures/flakes.

### Issue Context
- Upstream TS tests:
 - skip `worktree nested inside main repo` on Windows CI
 - skip `option-like diff ref` on Windows CI

### Fix Focus Areas
- pnpm/crates/workspace-projects-filter/src/filter/tests.rs[634-701]

### Suggested fix
Add an early return guard at the start of these tests, equivalent to upstream:

```rust
if cfg!(windows) && std::env::var_os("CI").is_some() {
   return;
}
```

(Alternatively, consider `#[cfg_attr(windows, ignore)]` if you decide the tests should always be skipped on Windows, not just on CI.)

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


5. Upstream-port comment in tests 📘 Rule violation ⚙ Maintainability ⭐ New
Description
Several new doc comments describe that tests are a "Port of upstream" rather than documenting
current behavior or intent. This introduces historical/provenance commentary inline instead of
focusing on current behavior.
Code

pnpm/crates/cli/tests/list.rs[R101-105]

+/// Port of upstream's `changedFilesIgnorePattern is respected`
+/// (`pnpm/test/monorepo/index.ts`): files matching the
+/// `changedFilesIgnorePattern` workspace setting don't count as changes
+/// for a `[<since>]` filter, and an empty `--changed-files-ignore-pattern=`
+/// CLI override disables the yaml patterns.
Evidence
PR Compliance ID 772199 forbids comments that focus on historical context instead of current
behavior. The cited comments primarily record that the tests were ported from upstream files rather
than describing the present contract/intent of the tests.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/cli/tests/list.rs[101-105]
pnpm/crates/cli/tests/run_recursive.rs[1280-1285]
pnpm/crates/config/src/workspace_yaml/tests.rs[541-544]

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

## Issue description
New comments like `Port of upstream's ...` document provenance/history instead of describing the current behavior/contract being tested.

## Issue Context
Inline comments should describe current behavior and rationale; historical notes belong in PR description or dedicated docs.

## Fix Focus Areas
- pnpm/crates/cli/tests/list.rs[101-105]
- pnpm/crates/cli/tests/run_recursive.rs[1280-1285]
- pnpm/crates/config/src/workspace_yaml/tests.rs[541-544]

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


6. Unescaped git stderr in error 🐞 Bug ⛨ Security
Description
get_changed_dirs_since_commit() forwards git diff stderr verbatim into
FilterError::FilterChanged, and the error’s display string interpolates it directly. Since git’s
stderr includes the user-supplied [<since>] token on bad revisions, a crafted selector can inject
arbitrary text/control characters into CI logs/terminal output when the diff fails.
Code

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[R91-101]

+    let output = Command::new("git")
+        .args(["diff", "--name-only", "--end-of-options", commit, "--"])
+        .arg(opts.workspace_dir)
+        .current_dir(opts.workspace_dir)
+        .output()
+        .map_err(|err| FilterError::FilterChanged { stderr: err.to_string() })?;
+    if !output.status.success() {
+        let stderr = String::from_utf8_lossy(&output.stderr);
+        return Err(FilterError::FilterChanged {
+            stderr: strip_final_newline(&stderr).to_string(),
+        });
Evidence
The Rust implementation captures stderr from git diff and returns it in FilterChanged, whose
Display implementation prints it inline. The tests assert that the bad-revision error string
contains the user-supplied revision token, proving user input is reflected into the rendered error
message.

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[88-101]
pacquet/crates/workspace-projects-filter/src/filter.rs[74-84]
pacquet/crates/workspace-projects-filter/src/filter/tests.rs[611-631]

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

### Issue description
`git diff` stderr is treated as untrusted output but is embedded verbatim into a user-facing diagnostic (`Filtering by changed packages failed. {stderr}`). Git error messages reflect the revision token, so a malicious `[<since>]` value can inject misleading or control-character-containing text into logs/terminals.

### Issue Context
- The error is constructed from `output.stderr` and rendered via `derive_more::Display` on `FilterError::FilterChanged`.
- The test suite demonstrates the user-provided revision being reflected into the error string.
- pnpm’s TypeScript implementation has the same pattern; if you harden output, keep pacquet/pnpm parity.

### Fix Focus Areas
- pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[88-101]
- pacquet/crates/workspace-projects-filter/src/filter.rs[74-84]
- pnpm11/workspace/projects-filter/src/getChangedProjects.ts[78-81]

### Suggested approach
- Sanitize/escape control characters in stderr before storing/formatting (e.g., remove ASCII control chars except `\n`/`\t`, or escape them to visible sequences).
- Apply the same sanitization in the TypeScript implementation (parity rule), or otherwise ensure both stacks’ rendered messages match.

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


View more (5)
7. Brittle git stderr assertion 🐞 Bug ☼ Reliability
Description
The new selection_fails_for_nonexistent_diff_branch test asserts an exact git error string, but
git’s human-formatted stderr can vary by locale/version/platform, making the test flaky despite
correct behavior. This can intermittently break CI for unrelated changes.
Code

pacquet/crates/workspace-projects-filter/src/filter/tests.rs[R626-631]

+        dbg!(&error);
+        assert!(matches!(error, FilterError::FilterChanged { .. }));
+        assert_eq!(
+            error.to_string(),
+            "Filtering by changed packages failed. fatal: bad revision 'branch-does-no-exist'",
+        );
Evidence
The test hard-codes git’s full stderr message via assert_eq!, which is known to vary across
environments and therefore risks non-deterministic failures.

pacquet/crates/workspace-projects-filter/src/filter/tests.rs[626-631]

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

### Issue description
`selection_fails_for_nonexistent_diff_branch` asserts `error.to_string()` equals a fully specific git stderr message. Git’s stderr text is not a stable interface and can vary, causing test flakiness.

### Issue Context
This is a unit test for the changed-packages (`[<since>]`) selector error path.

### Fix Focus Areas
- pacquet/crates/workspace-projects-filter/src/filter/tests.rs[626-631]

### Suggested fix
Replace the exact `assert_eq!(error.to_string(), ...)` with assertions on stable properties, e.g.:
- `assert!(matches!(error, FilterError::FilterChanged { .. }))`
- `let msg = error.to_string(); assert!(msg.contains("Filtering by changed packages failed."));`
- `assert!(msg.contains("bad revision"));`
- (optionally) `assert!(msg.contains("branch-does-no-exist"));`

This preserves behavior verification without depending on git’s exact wording.

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


8. strip_final_newline docs mismatch 📘 Rule violation ⚙ Maintainability
Description
The doc comment says strip_final_newline removes a final \n (and a preceding \r), but the
implementation also strips a lone trailing \r even when no \n is present. This makes the
documented contract inaccurate and can cause subtle behavior divergence for CR-only line endings.
Code

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[R132-138]

+/// Strip one final `\n` (and a preceding `\r`, if any) — execa's
+/// `stripFinalNewline` behavior, which upstream's process output goes
+/// through before it is parsed or embedded in an error message.
+fn strip_final_newline(text: &str) -> &str {
+    let text = text.strip_suffix('\n').unwrap_or(text);
+    text.strip_suffix('\r').unwrap_or(text)
+}
Evidence
Compliance rule 713450 requires doc comments to accurately describe the function’s contract. The
comment claims only a final \n (and its preceding \r) is stripped, but the code unconditionally
strips a trailing \r after attempting to strip \n, which changes the contract and can change
observable output.

Rule 713450: Doc comments must describe the function contract, not its implementation
pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[132-138]

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

## Issue description
`strip_final_newline()`'s doc comment says it strips one final `\n` (and a preceding `\r`), but the function currently strips a trailing `\r` even if there was no trailing `\n`. This makes the contract described by the docs inaccurate and may break intended parity with execa's `stripFinalNewline` behavior.

## Issue Context
This helper is used for both parsing `git diff --name-only` output and surfacing git stderr in `FilterError::FilterChanged`, so correctness and user-visible parity matter.

## Fix Focus Areas
- pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[132-138]

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


9. Changeset uses patch bump ✓ Resolved 📘 Rule violation § Compliance
Description
The added changeset marks pnpm as a patch, but the changeset text describes adding new
user-visible CLI behavior (changed-packages selector support and related flags). This may require a
minor bump per the changeset policy.
Code

.changeset/pacquet-changed-packages-filter.md[R1-5]

+---
+"pnpm": patch
+---
+
+The native pnpm CLI now supports the changed-packages filter selector (`--filter "...[<since>]"`), selecting the workspace projects whose files changed since the given git ref. The `testPattern` and `changedFilesIgnorePattern` settings (and the `--test-pattern` / `--changed-files-ignore-pattern` flags) are honored, matching the TypeScript CLI.
Evidence
The changeset explicitly sets "pnpm": patch while describing newly supported CLI selector/flags,
which the checklist treats as a minor-level change.

Rule 713436: Explicitly declare pnpm package and correct bump type in changesets
.changeset/pacquet-changed-packages-filter.md[1-5]

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 declares a `patch` bump for `pnpm`, but the changeset body describes new user-visible CLI functionality.

## Issue Context
Per the compliance rule, user-facing new features/settings should be released as `minor` unless this is strictly a bug fix in existing functionality.

## Fix Focus Areas
- .changeset/pacquet-changed-packages-filter.md[1-5]

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


10. Unvalidated git revision token ✓ Resolved 🐞 Bug ☼ Reliability
Description
The [<since>] selector’s raw <since> string is passed directly as the revision argument to `git
diff; if it begins with -`, git can interpret it as an option-like token, causing unexpected
failures/behavior instead of a clean “bad revision” error.
Code

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[R88-93]

+    let output = Command::new("git")
+        .args(["diff", "--name-only", commit, "--"])
+        .arg(opts.workspace_dir)
+        .current_dir(opts.workspace_dir)
+        .output()
+        .map_err(|err| FilterError::FilterChanged { stderr: err.to_string() })?;
Evidence
parse_project_selector stores the raw bracket contents as ProjectSelector.diff without
constraining the format, and get_changed_dirs_since_commit passes that value as the revision
argument to git diff. The repo’s security guidance also explicitly calls out preventing
command/argument injection and not passing attacker-controlled values as executable flags, which is
aligned with validating this token before using it in a subprocess invocation.

pacquet/crates/workspace-projects-filter/src/parse_project_selector.rs[60-71]
pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[80-100]
REVIEW_GUIDE.md[76-78]

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

## Issue description
`get_changed_dirs_since_commit` forwards `<since>` directly into `git diff`’s argv. Tokens starting with `-` are ambiguous in many CLIs and can be parsed as options, leading to confusing errors or behavior.

## Issue Context
`ProjectSelector.diff` is populated directly from the bracket contents of the `--filter` selector. That value flows unchanged into the `git diff` invocation.

## Fix Focus Areas
- pacquet/crates/workspace-projects-filter/src/parse_project_selector.rs[60-71]
- pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[80-100]

### Implementation direction
- Reject/diagnose diff refs that start with `-` (and possibly other clearly-invalid ref forms) before spawning `git`, returning a deterministic error (ideally matching pnpm’s error text expectations).
- Keep the current stderr-surfacing behavior for real git failures.

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


11. get_changed_projects takes Vec 📘 Rule violation ➹ Performance
Description
get_changed_projects() takes project_dirs as an owned Vec<PathBuf>, which forces
filter_graph to clone and collect the full workspace project directory set—often repeatedly per
[<since>] selector—creating avoidable allocation/clone overhead in the changed-packages selector
path. This extra work can become noticeable on large workspaces or when multiple diff selectors are
used (e.g., in recursive pn -r/CI affected-package selection).
Code

pacquet/crates/workspace-projects-filter/src/filter.rs[R169-176]

+            let changed = get_changed_projects(
+                projects_graph.keys().cloned().collect(),
+                diff,
+                &GetChangedProjectsOptions {
+                    workspace_dir: selector.parent_dir.as_deref().unwrap_or(&opts.workspace_dir),
+                    test_pattern: &opts.test_pattern,
+                    changed_files_ignore_pattern: &opts.changed_files_ignore_pattern,
+                },
Evidence
The API shape requires callers to pass an owned Vec<PathBuf>, and the selector implementation in
filter.rs satisfies this by doing a .collect() allocation from
projects_graph.keys().cloned().collect(). Because this collection is performed inside the
per-selector loop whenever a diff ([<since>]) selector is encountered, the entire keyset is cloned
repeatedly, demonstrating both the forced allocation imposed by the API and the repeated overhead at
the call site; the checklist guidance reinforces that a more general borrowed/generic parameter type
should be used when ownership isn’t required.

Rule 713447: Use the most general borrowed parameter types to avoid unnecessary allocations
pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[31-46]
pacquet/crates/workspace-projects-filter/src/filter.rs[166-177]
pacquet/crates/cli/src/cli_args/recursive.rs[308-338]

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

## Issue description
`get_changed_projects(project_dirs: Vec<PathBuf>, ...)` unnecessarily requires ownership, forcing call sites to allocate and clone a `Vec<PathBuf>` (via `collect()`) even when they already have an iterator/borrowed view of project roots, and `filter_graph` currently rebuilds that full list inside the per-selector loop for each `[<since>]` selector.

## Issue Context
The selector implementation calls `projects_graph.keys().cloned().collect()` solely to satisfy the `Vec<PathBuf>` parameter, and it does so within the selectors loop, causing repeated cloning of the entire workspace keyset when multiple diff selectors are present. This path is hit for `[<since>]` selectors used in recursive selection plumbing (e.g., `pn -r`) and CI workflows like affected-package selection, so the overhead can matter on large workspaces.

Acceptable implementation directions:
- Hoist project-dir collection once per `filter_graph` call and adjust `get_changed_projects` to accept a borrowed slice/iterator so you don’t need to deep-clone `PathBuf`s for unchanged projects.
- Alternatively, change `get_changed_projects` to operate on indices or `&PathBuf` keys internally and only clone the selected project dirs when returning.

## Fix Focus Areas
- pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs[36-46]
- pacquet/crates/workspace-projects-filter/src/filter.rs[166-177]

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


Grey Divider

Qodo Logo

@github-actions

github-actions Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
tarball/download_dependency    1.02      6.7±0.22ms   645.8 KB/sec    1.00      6.6±0.13ms   655.9 KB/sec

@qodo-code-review

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

Copy link
Copy Markdown

PR Code Suggestions ✨

Latest suggestions up to f4be7ef

Warning

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

CategorySuggestion                                                                                                                                    Impact
Possible issue
Parse git paths losslessly

Use git diff --name-only -z to handle file paths with non-ASCII characters
correctly without manually stripping quotes.

pnpm/crates/workspace-projects-filter/src/get_changed_projects.rs [91-117]

 let output = Command::new("git")
-    .args(["diff", "--name-only", "--end-of-options", commit, "--"])
+    .args(["diff", "--name-only", "-z", "--end-of-options", commit, "--"])
     .arg(opts.workspace_dir)
     .current_dir(opts.workspace_dir)
     .output()
     .map_err(|err| FilterError::FilterChanged { stderr: err.to_string() })?;
 ...
-let stdout = String::from_utf8_lossy(&output.stdout);
-let diff = strip_final_newline(&stdout);
-if diff.is_empty() {
+if output.stdout.is_empty() {
     return Ok(IndexMap::new());
 }
 
 let ignore_globs = compile_globs(opts.changed_files_ignore_pattern)?;
 let test_globs = compile_globs(opts.test_pattern)?;
 
+let stdout = String::from_utf8_lossy(&output.stdout);
 let mut changed_dirs: IndexMap<PathBuf, ChangeType> = IndexMap::new();
-for line in diff.split('\n') {
-    // git wraps paths with non-ASCII characters in quotes.
-    let changed_file = line.strip_prefix('"').unwrap_or(line);
-    let changed_file = changed_file.strip_suffix('"').unwrap_or(changed_file);
+for changed_file in stdout.split('\0').filter(|path| !path.is_empty()) {

[To ensure code accuracy, apply this suggestion manually]

Suggestion importance[1-10]: 9

__

Why: Using -z with git diff is the correct and robust way to handle file paths with special or non-ASCII characters, resolving a real edge-case in the current implementation.

High
  • More

Previous suggestions

Suggestions up to commit 7b13c0c
CategorySuggestion                                                                                                                                    Impact
Possible issue
Filter test-only diff selections

Apply the name_pattern filter to the test-only projects before adding them to
the selection. This prevents unrelated test-only projects from being erroneously
selected.

pacquet/crates/workspace-projects-filter/src/filter.rs [168-212]

 if let Some(diff) = &selector.diff {
     let changed = get_changed_projects(
         projects_graph.keys().cloned().collect(),
         diff,
         &GetChangedProjectsOptions {
             workspace_dir: selector.parent_dir.as_deref().unwrap_or(&opts.workspace_dir),
             test_pattern: &opts.test_pattern,
             changed_files_ignore_pattern: &opts.changed_files_ignore_pattern,
         },
     )?;
     entry_projects = Some(changed.changed_projects);
+    let mut ignore_dependent_for_projects = changed.ignore_dependent_for_projects;
+
+    if let Some(name_pattern) = &selector.name_pattern {
+        if let Some(projects) = &entry_projects {
+            let candidates = name_candidates(projects_graph, projects);
+            entry_projects = Some(match_projects(&candidates, name_pattern));
+        }
+        let candidates = name_candidates(projects_graph, &ignore_dependent_for_projects);
+        ignore_dependent_for_projects = match_projects(&candidates, name_pattern);
+    }
+
     walk.select_entries(
         WalkFlags { include_dependents: false, ..WalkFlags::of(selector) },
-        &changed.ignore_dependent_for_projects,
+        &ignore_dependent_for_projects,
         &forward,
         &reverse,
     );
 } else if let Some(parent_dir) = selector.parent_dir.as_deref() {
     entry_projects = Some(match_projects_by_path(
         projects_graph,
         parent_dir,
         opts.use_glob_dir_filtering,
     ));
 }
 
-if let Some(name_pattern) = &selector.name_pattern {
-    let candidates: Vec<(PathBuf, Option<String>)> = match &entry_projects {
-        None => projects_graph
-            .values()
-            .map(|node| {
-                (node.package.root_dir().to_path_buf(), node.package.manifest_name().map(str::to_string))
-            })
-            .collect(),
-        Some(projects) => projects
-            .iter()
-            .filter_map(|dir| {
-                projects_graph.get(dir).map(|node| {
-                    (dir.clone(), node.package.manifest_name().map(str::to_string))
+if selector.diff.is_none() {
+    if let Some(name_pattern) = &selector.name_pattern {
+        let candidates: Vec<(PathBuf, Option<String>)> = match &entry_projects {
+            None => projects_graph
+                .values()
+                .map(|node| {
+                    (node.package.root_dir().to_path_buf(), node.package.manifest_name().map(str::to_string))
                 })
-            })
-            .collect(),
-    };
-    entry_projects = Some(match_projects(&candidates, name_pattern));
+                .collect(),
+            Some(projects) => name_candidates(projects_graph, projects),
+        };
+        entry_projects = Some(match_projects(&candidates, name_pattern));
+    }
 }
Suggestion importance[1-10]: 9

__

Why: Identifies a critical logic flaw where test-only changed projects bypass the name_pattern filtering, ensuring correct filter application.

High
Parse git paths safely

Use git diff --name-only -z to generate null-delimited output for accurate path
parsing. This removes the need to manually strip quotes and gracefully handles
paths with newlines or special characters.

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs [114-131]

-for line in diff.split('\n') {
-    // git wraps paths with non-ASCII characters in quotes.
-    let changed_file = line.strip_prefix('"').unwrap_or(line);
-    let changed_file = changed_file.strip_suffix('"').unwrap_or(changed_file);
-    if ignore_globs.iter().any(|glob| glob.is_match(changed_file)) {
+let output = Command::new("git")
+    .args(["diff", "--name-only", "-z", "--end-of-options", commit, "--"])
+    .arg(opts.workspace_dir)
+    .current_dir(opts.workspace_dir)
+    .output()
+    .map_err(|err| FilterError::FilterChanged { stderr: err.to_string() })?;
+
+...
+
+for changed_file in output.stdout.split(|byte| *byte == b'\0').filter(|path| !path.is_empty()) {
+    let changed_file = String::from_utf8_lossy(changed_file);
+    if ignore_globs.iter().any(|glob| glob.is_match(&changed_file)) {
         continue;
     }
-    let dir = Path::new(changed_file).parent().unwrap_or_else(|| Path::new("")).to_path_buf();
+    let dir = Path::new(changed_file.as_ref()).parent().unwrap_or_else(|| Path::new("")).to_path_buf();
     if changed_dirs.get(&dir) == Some(&ChangeType::Source) {
         continue;
     }
-    let change_type = if test_globs.iter().any(|glob| glob.is_match(changed_file)) {
+    let change_type = if test_globs.iter().any(|glob| glob.is_match(&changed_file)) {
         ChangeType::Test
     } else {
         ChangeType::Source
     };
     changed_dirs.insert(dir, change_type);
 }
Suggestion importance[1-10]: 8

__

Why: Improves parsing robustness by leveraging git's null-delimited output (-z), avoiding subtle bugs with file paths containing special characters or quotes.

Medium
Suggestions up to commit 473821e
CategorySuggestion                                                                                                                                    Impact
Possible issue
Filter test-only changes by name

Apply name_pattern filtering to ignore_dependent_for_projects to ensure
test-only changes respect the package name filter.

pacquet/crates/workspace-projects-filter/src/filter.rs [168-218]

+let mut ignore_dependent_for_projects: Vec<PathBuf> = Vec::new();
 if let Some(diff) = &selector.diff {
     let changed = get_changed_projects(
         projects_graph.keys().cloned().collect(),
         diff,
         &GetChangedProjectsOptions {
             workspace_dir: selector.parent_dir.as_deref().unwrap_or(&opts.workspace_dir),
             test_pattern: &opts.test_pattern,
             changed_files_ignore_pattern: &opts.changed_files_ignore_pattern,
         },
     )?;
     entry_projects = Some(changed.changed_projects);
-    walk.select_entries(
-        WalkFlags { include_dependents: false, ..WalkFlags::of(selector) },
-        &changed.ignore_dependent_for_projects,
-        &forward,
-        &reverse,
-    );
+    ignore_dependent_for_projects = changed.ignore_dependent_for_projects;
 } else if let Some(parent_dir) = selector.parent_dir.as_deref() {
     entry_projects = Some(match_projects_by_path(
         projects_graph,
         parent_dir,
         opts.use_glob_dir_filtering,
     ));
 }
 
 if let Some(name_pattern) = &selector.name_pattern {
-    let candidates: Vec<(PathBuf, Option<String>)> = match &entry_projects {
-        None => projects_graph
-            .iter()
-            .map(|(dir, node)| (dir.clone(), node.package.manifest_name().map(str::to_string)))
-            .collect(),
-        Some(entries) => entries
+    let filter_by_name = |entries: &[PathBuf]| {
+        let candidates: Vec<(PathBuf, Option<String>)> = entries
             .iter()
             .filter_map(|dir| {
                 projects_graph.get(dir).map(|node| {
                     (dir.clone(), node.package.manifest_name().map(str::to_string))
                 })
             })
-            .collect(),
+            .collect();
+        match_projects(&candidates, name_pattern)
     };
-    entry_projects = Some(match_projects(&candidates, name_pattern));
+
+    entry_projects = Some(match &entry_projects {
+        None => {
+            let candidates: Vec<(PathBuf, Option<String>)> = projects_graph
+                .iter()
+                .map(|(dir, node)| {
+                    (dir.clone(), node.package.manifest_name().map(str::to_string))
+                })
+                .collect();
+            match_projects(&candidates, name_pattern)
+        }
+        Some(entries) => filter_by_name(entries),
+    });
+    ignore_dependent_for_projects = filter_by_name(&ignore_dependent_for_projects);
 }
 
+if !ignore_dependent_for_projects.is_empty() {
+    walk.select_entries(
+        WalkFlags { include_dependents: false, ..WalkFlags::of(selector) },
+        &ignore_dependent_for_projects,
+        &forward,
+        &reverse,
+    );
+}
+
Suggestion importance[1-10]: 9

__

Why: This fixes a significant logical bug where ignore_dependent_for_projects bypasses the name_pattern filter, causing test-only changes to be incorrectly included regardless of the package name filter.

High
Preserve non-ASCII diff paths

Use git -c core.quotePath=false to prevent Git from escaping non-ASCII paths,
ensuring they match correctly against the workspace directories.

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs [91-96]

 let output = Command::new("git")
-    .args(["diff", "--name-only", "--end-of-options", commit, "--"])
+    .args([
+        "-c",
+        "core.quotePath=false",
+        "diff",
+        "--name-only",
+        "--end-of-options",
+        commit,
+        "--",
+    ])
     .arg(opts.workspace_dir)
     .current_dir(opts.workspace_dir)
     .output()
     .map_err(|err| FilterError::FilterChanged { stderr: err.to_string() })?;
Suggestion importance[1-10]: 8

__

Why: Disabling core.quotePath ensures that git diff outputs raw bytes for paths with non-ASCII characters, avoiding path matching failures due to C-style escapes.

Medium
Suggestions up to commit a67082e
CategorySuggestion                                                                                                                                    Impact
Possible issue
Disable Git path escaping

Add -c core.quotePath=false to the git diff command to disable path quoting.

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs [88-92]

 let output = Command::new("git")
-    .args(["diff", "--name-only", commit, "--"])
+    .args(["-c", "core.quotePath=false", "diff", "--name-only", commit, "--"])
     .arg(opts.workspace_dir)
     .current_dir(opts.workspace_dir)
     .output()
Suggestion importance[1-10]: 9

__

Why: Adding -c core.quotePath=false prevents Git from escaping non-ASCII paths, which is crucial for accurately mapping changed files to workspace projects.

High
Filter test-only selections

Delay adding test-only changed projects to walk until after the name_pattern
filtering is applied.

pacquet/crates/workspace-projects-filter/src/filter.rs [168-185]

+let mut ignore_dependent_for_projects: Option<Vec<PathBuf>> = None;
 if let Some(diff) = &selector.diff {
     let changed = get_changed_projects(
         projects_graph.keys().cloned().collect(),
         diff,
         &GetChangedProjectsOptions {
             workspace_dir: selector.parent_dir.as_deref().unwrap_or(&opts.workspace_dir),
             test_pattern: &opts.test_pattern,
             changed_files_ignore_pattern: &opts.changed_files_ignore_pattern,
         },
     )?;
     entry_projects = Some(changed.changed_projects);
+    ignore_dependent_for_projects = Some(changed.ignore_dependent_for_projects);
+} else if let Some(parent_dir) = selector.parent_dir.as_deref() {
+...
+if let Some(name_pattern) = &selector.name_pattern {
+    ...
+}
+if let Some(ignore_dependent_for_projects) = ignore_dependent_for_projects.as_mut()
+    && let Some(name_pattern) = &selector.name_pattern
+{
+    let candidates: Vec<(PathBuf, Option<String>)> = ignore_dependent_for_projects
+        .iter()
+        .filter_map(|id| {
+            projects_graph
+                .get(id)
+                .map(|node| (id.clone(), node.package.manifest_name().map(str::to_string)))
+        })
+        .collect();
+    *ignore_dependent_for_projects = match_projects(&candidates, name_pattern);
+}
+if let Some(ignore_dependent_for_projects) = &ignore_dependent_for_projects {
     walk.select_entries(
         WalkFlags { include_dependents: false, ..WalkFlags::of(selector) },
-        &changed.ignore_dependent_for_projects,
+        ignore_dependent_for_projects,
         &forward,
         &reverse,
     );
-} else if let Some(parent_dir) = selector.parent_dir.as_deref() {
+}
Suggestion importance[1-10]: 9

__

Why: This fixes a bug where test-only changed projects bypassed the name_pattern filter and were incorrectly added to the walk selection.

High
Avoid corrupting paths

Remove the manual quote-stripping fallback for changed files.

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs [113-127]

-let changed_file = line.strip_prefix('"').unwrap_or(line);
-let changed_file = changed_file.strip_suffix('"').unwrap_or(changed_file);
-if ignore_globs.iter().any(|glob| glob.is_match(changed_file)) {
+if ignore_globs.iter().any(|glob| glob.is_match(line)) {
     continue;
 }
+let changed_file = line;
 let dir = Path::new(changed_file).parent().unwrap_or_else(|| Path::new("")).to_path_buf();
 if changed_dirs.get(&dir) == Some(&ChangeType::Source) {
     continue;
 }
 let change_type = if test_globs.iter().any(|glob| glob.is_match(changed_file)) {
     ChangeType::Test
 } else {
     ChangeType::Source
 };
 changed_dirs.insert(dir, change_type);
Suggestion importance[1-10]: 8

__

Why: Removing the manual quote-stripping prevents the accidental corruption of legitimate filenames that contain quotes, acting as a necessary follow-up to disabling Git's path quoting.

Medium
Suggestions up to commit c7d46f0
CategorySuggestion                                                                                                                                    Impact
Possible issue
Filter test-only diff selections

Filter both [] result sets by name_pattern before adding them to WalkState. This
prevents projects with test-only changes from bypassing the name filter.

pacquet/crates/workspace-projects-filter/src/filter.rs [168-227]

+let mut ignore_dependent_for_projects: Vec<PathBuf> = Vec::new();
+
 if let Some(diff) = &selector.diff {
     let changed = get_changed_projects(
         projects_graph.keys().cloned().collect(),
         diff,
         &GetChangedProjectsOptions {
             workspace_dir: selector.parent_dir.as_deref().unwrap_or(&opts.workspace_dir),
             test_pattern: &opts.test_pattern,
             changed_files_ignore_pattern: &opts.changed_files_ignore_pattern,
         },
     )?;
     entry_projects = Some(changed.changed_projects);
-    walk.select_entries(
-        WalkFlags { include_dependents: false, ..WalkFlags::of(selector) },
-        &changed.ignore_dependent_for_projects,
-        &forward,
-        &reverse,
-    );
+    ignore_dependent_for_projects = changed.ignore_dependent_for_projects;
 } else if let Some(parent_dir) = selector.parent_dir.as_deref() {
     entry_projects = Some(match_projects_by_path(
         projects_graph,
         parent_dir,
         opts.use_glob_dir_filtering,
     ));
 }
 
 if let Some(name_pattern) = &selector.name_pattern {
-    let candidates: Vec<(PathBuf, Option<String>)> = match &entry_projects {
-        None => projects_graph
-            .iter()
-            .map(|(dir, node)| {
-                (dir.clone(), node.package.manifest_name().map(str::to_string))
-            })
-            .collect(),
-        Some(dirs) => dirs
+    let filter_dirs_by_name = |dirs: &[PathBuf]| {
+        let candidates: Vec<(PathBuf, Option<String>)> = dirs
             .iter()
             .filter_map(|dir| {
                 projects_graph.get(dir).map(|node| {
                     (dir.clone(), node.package.manifest_name().map(str::to_string))
                 })
             })
-            .collect(),
+            .collect();
+        match_projects(&candidates, name_pattern)
     };
-    entry_projects = Some(match_projects(&candidates, name_pattern));
+
+    entry_projects = Some(match &entry_projects {
+        None => {
+            let candidates: Vec<(PathBuf, Option<String>)> = projects_graph
+                .iter()
+                .map(|(dir, node)| {
+                    (dir.clone(), node.package.manifest_name().map(str::to_string))
+                })
+                .collect();
+            match_projects(&candidates, name_pattern)
+        }
+        Some(dirs) => filter_dirs_by_name(dirs),
+    });
+    ignore_dependent_for_projects = filter_dirs_by_name(&ignore_dependent_for_projects);
 }
+
+walk.select_entries(
+    WalkFlags { include_dependents: false, ..WalkFlags::of(selector) },
+    &ignore_dependent_for_projects,
+    &forward,
+    &reverse,
+);
 ...
 walk.select_entries(WalkFlags::of(selector), &entry_projects, &forward, &reverse);
Suggestion importance[1-10]: 10

__

Why: The PR applies the name_pattern filter only to changed.changed_projects, allowing projects with test-only changes to incorrectly bypass the name filter and be selected regardless of their package name.

High
Suggestions up to commit fef7058
CategorySuggestion                                                                                                                                    Impact
Possible issue
Apply name_pattern to test-only changed projects

Apply the name_pattern filter to ignore_dependent_for_projects before passing
them to walk.select_entries.

pacquet/crates/workspace-projects-filter/src/filter.rs [169-184]

 let changed = get_changed_projects(
     projects_graph.keys().cloned().collect(),
     diff,
     &GetChangedProjectsOptions {
         workspace_dir: selector.parent_dir.as_deref().unwrap_or(&opts.workspace_dir),
         test_pattern: &opts.test_pattern,
         changed_files_ignore_pattern: &opts.changed_files_ignore_pattern,
     },
 )?;
 entry_projects = Some(changed.changed_projects);
+
+let mut test_only = changed.ignore_dependent_for_projects;
+if let Some(name_pattern) = &selector.name_pattern {
+    let candidates: Vec<(PathBuf, Option<String>)> = test_only
+        .iter()
+        .filter_map(|id| {
+            projects_graph.get(id).map(|node| {
+                (id.clone(), node.manifest_name().map(String::from))
+            })
+        })
+        .collect();
+    test_only = match_projects(&candidates, name_pattern);
+}
 walk.select_entries(
     WalkFlags { include_dependents: false, ..WalkFlags::of(selector) },
-    &changed.ignore_dependent_for_projects,
+    &test_only,
     &forward,
     &reverse,
 );
Suggestion importance[1-10]: 9

__

Why: This addresses a logical bug where test-only changed packages bypass the name_pattern filter and are incorrectly selected even if they don't match the required name pattern.

High
Use git diff -z to avoid path escaping issues

Use git diff -z and split by \0 to robustly handle file paths.

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs [84-116]

 fn get_changed_dirs_since_commit(
     commit: &str,
     opts: &GetChangedProjectsOptions<'_>,
 ) -> Result<IndexMap<PathBuf, ChangeType>, FilterError> {
     let output = Command::new("git")
-        .args(["diff", "--name-only", commit, "--"])
+        .args(["diff", "-z", "--name-only", commit, "--"])
         .arg(opts.workspace_dir)
         .current_dir(opts.workspace_dir)
         .output()
         .map_err(|err| FilterError::FilterChanged { stderr: err.to_string() })?;
     if !output.status.success() {
         return Err(FilterError::FilterChanged {
             stderr: String::from_utf8_lossy(&output.stderr).trim_end().to_string(),
         });
     }
 
     let stdout = String::from_utf8_lossy(&output.stdout);
-    let diff = stdout.trim_end_matches('\n');
+    let diff = stdout.trim_end_matches('\0');
     if diff.is_empty() {
         return Ok(IndexMap::new());
     }
 
     let ignore_globs = compile_globs(opts.changed_files_ignore_pattern)?;
     let test_globs = compile_globs(opts.test_pattern)?;
 
     let mut changed_dirs: IndexMap<PathBuf, ChangeType> = IndexMap::new();
-    for line in diff.split('\n') {
-        // git wraps paths with non-ASCII characters in quotes.
-        let changed_file = line.strip_prefix('"').unwrap_or(line);
-        let changed_file = changed_file.strip_suffix('"').unwrap_or(changed_file);
+    for changed_file in diff.split('\0') {
         if ignore_globs.iter().any(|glob| glob.is_match(changed_file)) {
             continue;
         }
Suggestion importance[1-10]: 8

__

Why: Using -z is the correct and robust way to process git diff output, as it avoids issues with Git's C-style escaping of paths containing spaces or non-ASCII characters.

Medium
Prevent non-project directories from being registered

Use get_mut instead of entry(...).or_insert(None) to prevent non-project
directories from being tracked.

pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs [52-59]

 while !project_change_types.contains_key(&current) {
     let Some(parent) = current.parent() else { break };
     current = parent.to_path_buf();
 }
-let entry = project_change_types.entry(current).or_insert(None);
-if *entry != Some(ChangeType::Source) {
-    *entry = Some(change_type);
+if let Some(entry) = project_change_types.get_mut(&current) {
+    if *entry != Some(ChangeType::Source) {
+        *entry = Some(change_type);
+    }
 }
Suggestion importance[1-10]: 7

__

Why: Using get_mut avoids unnecessarily populating the map with the file system root when a changed file resides outside any known project directory.

Medium

Copilot AI review requested due to automatic review settings July 10, 2026 15:33

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 c7d46f0

Copilot AI review requested due to automatic review settings July 10, 2026 15:43

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 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: 4

🧹 Nitpick comments (1)
pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs (1)

112-113: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Use -z (NUL-separated) output for robust path parsing.

Git wraps paths with special characters in C-style quotes (e.g., "foo\"bar.txt"). The current strip_prefix/strip_suffix approach only removes outer quotes without unescaping \", \\, etc., producing incorrect paths for files containing quotes or backslashes. Using git diff --name-only -z outputs NUL-separated paths without quoting, avoiding this entirely.

♻️ Proposed refactor: switch to NUL-separated parsing
     let output = Command::new("git")
-        .args(["diff", "--name-only", commit, "--"])
+        .args(["diff", "--name-only", "-z", commit, "--"])
         .arg(opts.workspace_dir)
         .current_dir(opts.workspace_dir)
         .output()
         .map_err(|err| FilterError::FilterChanged { stderr: err.to_string() })?;
     if !output.status.success() {
         return Err(FilterError::FilterChanged {
             stderr: String::from_utf8_lossy(&output.stderr).trim_end().to_string(),
         });
     }

-    let stdout = String::from_utf8_lossy(&output.stdout);
-    let diff = stdout.trim_end_matches('\n');
-    if diff.is_empty() {
+    let stdout = String::from_utf8_lossy(&output.stdout);
+    if stdout.is_empty() {
         return Ok(IndexMap::new());
     }

     let ignore_globs = compile_globs(opts.changed_files_ignore_pattern)?;
     let test_globs = compile_globs(opts.test_pattern)?;

     let mut changed_dirs: IndexMap<PathBuf, ChangeType> = IndexMap::new();
-    for line in diff.split('\n') {
-        // git wraps paths with non-ASCII characters in quotes.
-        let changed_file = line.strip_prefix('"').unwrap_or(line);
-        let changed_file = changed_file.strip_suffix('"').unwrap_or(changed_file);
+    for changed_file in stdout.split('\0') {
+        if changed_file.is_empty() {
+            continue;
+        }
         if ignore_globs.iter().any(|glob| glob.is_match(changed_file)) {
             continue;
         }
🤖 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 `@pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs` around
lines 112 - 113, Update the git diff invocation used by the changed-projects
logic to request NUL-separated output with `-z`, then parse the result by
splitting on NUL bytes instead of lines. Remove the outer-quote stripping in the
changed-file parsing near `get_changed_projects`, and preserve paths exactly as
emitted, including quotes and backslashes.
🤖 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 `@pacquet/crates/workspace-projects-filter/src/filter/tests.rs`:
- Line 626: Add a dbg! call for error immediately before the
assert!(matches!(error, FilterError::FilterChanged { .. })) assertion in the
relevant test, following CODE_STYLE_GUIDE.md so the actual value is logged
before a potential assertion failure.
- Around line 408-631: Validate ProjectSelector::diff in the changed-projects
git invocation before spawning the process; reject any ref beginning with “-”
(or normalize it as an explicit revision) so values such as “--help” cannot be
interpreted as git options. Update the resulting error handling and tests,
including selection_fails_for_nonexistent_diff_branch, to cover leading-dash
refs.

In `@pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs`:
- Around line 88-93: Validate the user-provided commit ref before constructing
the git command in the changed-project filtering logic. Reject any commit value
beginning with "-" and return an appropriate FilterError::FilterChanged; ensure
this validation occurs before Command::new("git") is invoked, while preserving
valid refs and existing error handling.
- Around line 148-155: Update find_repo_root to scan ancestors once and return
the nearest .git entry regardless of whether it is a file or directory; remove
the directory-first then file-second search so nested worktrees resolve to their
own repository root.

---

Nitpick comments:
In `@pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs`:
- Around line 112-113: Update the git diff invocation used by the
changed-projects logic to request NUL-separated output with `-z`, then parse the
result by splitting on NUL bytes instead of lines. Remove the outer-quote
stripping in the changed-file parsing near `get_changed_projects`, and preserve
paths exactly as emitted, including quotes and backslashes.
🪄 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: 47594074-7167-44b8-b7dc-3da47fb52241

📥 Commits

Reviewing files that changed from the base of the PR and between a38adda and fef7058.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (17)
  • .changeset/pacquet-changed-packages-filter.md
  • pacquet/crates/cli/src/cli_args/cli_command.rs
  • pacquet/crates/cli/src/cli_args/deploy.rs
  • pacquet/crates/cli/src/cli_args/dispatch.rs
  • pacquet/crates/cli/src/cli_args/recursive.rs
  • pacquet/crates/cli/tests/exec_recursive.rs
  • pacquet/crates/cli/tests/run_recursive.rs
  • pacquet/crates/config/src/env_overlay.rs
  • pacquet/crates/config/src/lib.rs
  • pacquet/crates/config/src/workspace_yaml.rs
  • pacquet/crates/package-manager/src/install_package_from_registry/tests.rs
  • pacquet/crates/workspace-projects-filter/Cargo.toml
  • pacquet/crates/workspace-projects-filter/src/filter.rs
  • pacquet/crates/workspace-projects-filter/src/filter/tests.rs
  • pacquet/crates/workspace-projects-filter/src/get_changed_projects.rs
  • pacquet/crates/workspace-projects-filter/src/lib.rs
  • pacquet/plans/TEST_PORTING.md

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit a67082e

@codecov-commenter

codecov-commenter commented Jul 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.51%. Comparing base (8e17c3d) to head (f4be7ef).

Files with missing lines Patch % Lines
...kspace-projects-filter/src/get_changed_projects.rs 94.56% 5 Missing ⚠️
pnpm/crates/cli/src/cli_args/dispatch.rs 87.50% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12914      +/-   ##
==========================================
+ Coverage   85.49%   85.51%   +0.01%     
==========================================
  Files         468      469       +1     
  Lines       72828    72988     +160     
==========================================
+ Hits        62266    62414     +148     
- Misses      10562    10574      +12     

☔ 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.

Copilot AI review requested due to automatic review settings July 10, 2026 16:02

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 473821e

Copilot AI review requested due to automatic review settings July 10, 2026 16:07

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.

zkochan and others added 5 commits July 10, 2026 18:09
Port git-diff project selection from `@pnpm/workspace.projects-filter`
to pacquet, so a `--filter "...[origin/main]"` selector selects the
workspace projects whose files changed since the given git ref instead
of failing with `unsupported_diff_selector`. This unblocks the
`ci:test-branch` job, whose
`pn --filter=...[origin/main] -r list --depth=-1 --json` discovery step
fails on every PR with the pacquet-based `@pnpm/exe`.

The port mirrors upstream `getChangedProjects`:

- `git diff --name-only <since> -- <workspace_dir>` runs in the
  selector's `{dir}` (else the workspace root); the repository root the
  diff paths are relative to is the parent of the nearest `.git`
  directory, falling back to the nearest `.git` file (worktrees).
- Each changed file maps to the nearest enclosing workspace project.
  Files matching `changedFilesIgnorePattern` are ignored entirely;
  projects whose changes all match `testPattern` are selected without
  their dependents. Both pattern sets are matched with `wax`, the glob
  crate pacquet already uses where upstream uses micromatch/fast-glob.
- A failing git diff surfaces git's stderr under pnpm's
  `ERR_PNPM_FILTER_CHANGED` error code.

`FilterWorkspaceProjectsOptions` / `FilterProjectsOptions` gain
`workspace_dir`, `test_pattern`, and `changed_files_ignore_pattern`,
threaded from `Config` by the recursive commands and `deploy`. The
`testPattern` / `changedFilesIgnorePattern` settings are read from
`pnpm-workspace.yaml` and `PNPM_CONFIG_*` env vars, overridable by the
global `--test-pattern` / `--changed-files-ignore-pattern` flags, and
excluded from the global config.yaml — all matching the TypeScript CLI.

The three upstream diff-selector tests (basic selection incl. quoted
non-ASCII paths, git-worktree layout, nonexistent ref error) are ported
from their `known_failures` stubs into `filter::tests::changed_packages`,
and the recursive run/exec integration tests now assert the selector
scopes execution to the changed project. Verified against the
TypeScript CLI on this repository: both stacks select the identical
project set for `...[origin/main]`, with and without the two pattern
flags.

Co-Authored-By: Claude Fable 5 <[email protected]>
Port the rest of the upstream tests around the `[<since>]` selector:

- `testPattern is respected by the test script`
  (`pnpm/test/monorepo/index.ts`) as a recursive-run integration test:
  `testPattern` read from `pnpm-workspace.yaml`, a `...[origin/main]`
  filter against a pushed origin ref, and dependents of a
  test-only-changed project staying unselected.
- `changedFilesIgnorePattern is respected` (same file) as a list
  integration test: yaml-configured ignore patterns (including a brace
  alternation and `**/cache/**`), an uncommitted working-tree change,
  and the empty `--changed-files-ignore-pattern=` CLI override
  disabling the yaml patterns.
- `respects testPattern` / `respects changedFilesIgnorePattern`
  (`config/reader/test/index.ts`) as workspace-yaml config tests,
  plus their exclusion from the global config.yaml. The upstream
  `.npmrc`-is-ignored case has no pacquet counterpart because pacquet
  reads no settings from `.npmrc`.

Each new test was verified to fail with the yaml-to-config threading
deliberately broken. The upstream parse-cli-args case for
`--test-pattern` consuming exactly one value is enforced by clap's
declared arity in pacquet, so it is not ported.

Co-Authored-By: Claude Fable 5 <[email protected]>
Match execa's stripFinalNewline, which upstream's git stderr and stdout
pass through: remove one trailing LF (plus a preceding CR), instead of
trimming all trailing whitespace from the ERR_PNPM_FILTER_CHANGED
message and the diff file list.

Co-Authored-By: Claude Fable 5 <[email protected]>
…trees

Address two review findings in the `[<since>]` changed-packages
selector, in both stacks (the TypeScript CLI and pacquet) since both
shared the same behavior:

- Pass --end-of-options to `git diff --name-only` so an option-like
  `<since>` value cannot be parsed as a git option. Without it,
  `--filter "[--output=<path>]"` made git write its diff output to an
  arbitrary file and exit 0; now git rejects the value as a bad
  revision (ERR_PNPM_FILTER_CHANGED).
- Resolve the repository root to the *nearest* `.git` entry, file or
  directory, instead of preferring a `.git` directory anywhere up the
  tree. A worktree checked out inside another repository's tree has a
  `.git` file while an ancestor has a `.git` directory; the old
  dir-first search anchored diff paths at the wrong root, so changed
  projects stopped matching. TypeScript switches `find.dir ?? find.file`
  to `find.up`; pacquet's find_repo_root does a single nearest-entry
  scan.

Both fixes carry matching tests in both stacks, each verified to fail
against the previous behavior. Also adds a `dbg!` before the
non-assert_eq error assertion in the nonexistent-ref test, per the
style guide.

Co-Authored-By: Claude Fable 5 <[email protected]>
Changesets are not created for Rust-only changes. The remaining
changeset covers the TypeScript-side fixes in
`@pnpm/workspace.projects-filter` (--end-of-options hardening and
nearest-.git repo-root resolution).

Co-Authored-By: Claude Fable 5 <[email protected]>
@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 10, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 7b13c0c

Copilot AI review requested due to automatic review settings July 10, 2026 16:15
@zkochan
zkochan force-pushed the pq-git-diff-filter branch from 7b13c0c to f4be7ef Compare July 10, 2026 16:15

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 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.

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

136-182: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Extract the duplicated git test helper.

The git closure (lines 142–153) is duplicated verbatim in list.rs (lines 131–139) and run_recursive.rs (lines 655–666 and 1313–1324) — four copies total across three files. Consider extracting a shared git(cwd: &Path, args: &[&str]) helper into pacquet-testing-utils alongside CommandTempCwd, so all CLI integration tests can reuse it.

As per coding guidelines, missed reuse or duplication across the monorepo should be surfaced. Based on learnings, the pacquet-testing-utils crate already provides shared test infrastructure (CommandTempCwd), making it the natural home for this helper.

🤖 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/exec_recursive.rs` around lines 136 - 182, Extract the
duplicated git command closure into a shared git(cwd: &Path, args: &[&str])
helper in the pacquet-testing-utils crate alongside CommandTempCwd, preserving
its command execution and failure diagnostics. Update
recursive_exec_diff_selector_selects_changed_projects and the corresponding
helpers/usages in list.rs and run_recursive.rs to call the shared helper,
removing all local duplicate closures.

Sources: Path instructions, Learnings

🤖 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.

Nitpick comments:
In `@pnpm/crates/cli/tests/exec_recursive.rs`:
- Around line 136-182: Extract the duplicated git command closure into a shared
git(cwd: &Path, args: &[&str]) helper in the pacquet-testing-utils crate
alongside CommandTempCwd, preserving its command execution and failure
diagnostics. Update recursive_exec_diff_selector_selects_changed_projects and
the corresponding helpers/usages in list.rs and run_recursive.rs to call the
shared helper, removing all local duplicate closures.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 19253603-a3c0-4f87-bfa9-048919ac3360

📥 Commits

Reviewing files that changed from the base of the PR and between 473821e and f4be7ef.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock, !Cargo.lock
📒 Files selected for processing (8)
  • .changeset/changed-packages-filter-hardening.md
  • pnpm/crates/cli/src/cli_args/cli_command.rs
  • pnpm/crates/cli/src/cli_args/deploy.rs
  • pnpm/crates/cli/src/cli_args/dispatch.rs
  • pnpm/crates/cli/src/cli_args/recursive.rs
  • pnpm/crates/cli/tests/exec_recursive.rs
  • pnpm/crates/cli/tests/list.rs
  • pnpm/crates/cli/tests/run_recursive.rs
✅ Files skipped from review due to trivial changes (1)
  • .changeset/changed-packages-filter-hardening.md

Comment on lines +594 to +597
test('select changed packages when operating under a git worktree nested inside the main repository', async () => {
if (isCI && isWindows()) {
return
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Action required

1. Windows ci test early-return 📘 Rule violation ▣ Testability

The newly added Jest tests return early on CI Windows without an issue reference or explicit
justification, effectively skipping coverage on that platform. This violates the requirement to
avoid introducing skipped/ignored tests without tracked rationale.
Agent Prompt
## Issue description
New tests are conditionally skipped on CI Windows via `if (isCI && isWindows()) { return }` without a linked tracking issue or documented justification.

## Issue Context
The compliance rule requires that newly skipped/ignored tests include an explicit issue reference and rationale, or the tests should be made to pass on that platform.

## Fix Focus Areas
- pnpm11/workspace/projects-filter/test/index.ts[594-597]
- pnpm11/workspace/projects-filter/test/index.ts[658-661]

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

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f4be7ef

@github-actions

Copy link
Copy Markdown
Contributor

Integrated-Benchmark Report (Linux)

Commit: f4be7ef22229

Each scenario reports direct installs and pnpr installs. Bencher consumes pacquet@HEAD and pnpr@HEAD.

Scenario: Isolated linker: fresh restore, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.179 ± 0.189 4.051 4.669 1.97 ± 0.15
pacquet@main 4.048 ± 0.204 3.834 4.471 1.90 ± 0.16
pnpr@HEAD 2.146 ± 0.127 2.026 2.373 1.01 ± 0.09
pnpr@main 2.126 ± 0.136 1.960 2.400 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.17897903716,
      "stddev": 0.18883663556439295,
      "median": 4.108338824860001,
      "user": 3.9119701399999998,
      "system": 3.6201947,
      "min": 4.05126679336,
      "max": 4.66860715236,
      "times": [
        4.13912264936,
        4.07755500036,
        4.05427137536,
        4.07381677436,
        4.66860715236,
        4.28531250436,
        4.06142442336,
        4.16612236436,
        4.21229133436,
        4.05126679336
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.04788309046,
      "stddev": 0.20376662808730323,
      "median": 3.97704666736,
      "user": 3.82576744,
      "system": 3.5573829000000003,
      "min": 3.8341930893600003,
      "max": 4.47051093536,
      "times": [
        4.47051093536,
        4.17186565736,
        3.97065676136,
        3.84166162236,
        4.13057470936,
        3.98187988736,
        3.86745973736,
        4.23781505736,
        3.97221344736,
        3.8341930893600003
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.1460213873600003,
      "stddev": 0.12698769059040807,
      "median": 2.10643901586,
      "user": 2.7437204399999997,
      "system": 3.1069432000000003,
      "min": 2.02579538736,
      "max": 2.37319719636,
      "times": [
        2.02579538736,
        2.16768494336,
        2.04706958336,
        2.12076503536,
        2.36325504036,
        2.03591873036,
        2.09211299636,
        2.37319719636,
        2.16352927936,
        2.07088568136
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.12600252706,
      "stddev": 0.13624564257875404,
      "median": 2.08165964986,
      "user": 2.67743094,
      "system": 3.0965730000000002,
      "min": 1.96022895836,
      "max": 2.40019142536,
      "times": [
        2.09418528736,
        2.20277931236,
        1.96022895836,
        2.30255534436,
        2.06375064536,
        2.40019142536,
        2.06913401236,
        2.09560628236,
        2.00401485936,
        2.06757914336
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, hot cache + hot store

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 676.4 ± 9.7 660.8 690.0 1.02 ± 0.02
pacquet@main 660.6 ± 9.1 650.1 675.8 1.00
pnpr@HEAD 737.6 ± 68.5 693.5 928.4 1.12 ± 0.10
pnpr@main 732.7 ± 13.3 708.7 750.0 1.11 ± 0.03
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6763846275,
      "stddev": 0.009695881540528592,
      "median": 0.6751600179,
      "user": 0.41758296,
      "system": 1.3585777799999998,
      "min": 0.6608334279,
      "max": 0.6900456499000001,
      "times": [
        0.6900456499000001,
        0.6811948019,
        0.6726365679,
        0.6724689429,
        0.6608334279,
        0.6848346999,
        0.6695881009,
        0.6776834679,
        0.6883306799000001,
        0.6662299359
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6605768663000001,
      "stddev": 0.00914285420428677,
      "median": 0.6565711209,
      "user": 0.40519836,
      "system": 1.3292317799999998,
      "min": 0.6501346419,
      "max": 0.6757728889000001,
      "times": [
        0.6694457079,
        0.6570575739000001,
        0.6560846679000001,
        0.6532858359,
        0.6539098639,
        0.6501346419,
        0.6757728889000001,
        0.6610678209,
        0.6737902599000001,
        0.6552194019
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.7376285817,
      "stddev": 0.06851363848251114,
      "median": 0.7160536004,
      "user": 0.43055956,
      "system": 1.3773391799999997,
      "min": 0.6934795699,
      "max": 0.9283748099000001,
      "times": [
        0.7098349859,
        0.7458802339,
        0.7073854569,
        0.7160959209000001,
        0.7161596189,
        0.7326788849,
        0.7103850559,
        0.6934795699,
        0.7160112799,
        0.9283748099000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.7327439673,
      "stddev": 0.013301919175837998,
      "median": 0.7346260979000001,
      "user": 0.41300245999999996,
      "system": 1.42283688,
      "min": 0.7087120469,
      "max": 0.7499768249000001,
      "times": [
        0.7248955699,
        0.7465517929000001,
        0.7416187899000001,
        0.7087120469,
        0.7433882589,
        0.7324517669,
        0.7231418319,
        0.7368004289000001,
        0.7199023619,
        0.7499768249000001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + cold store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 4.397 ± 0.042 4.349 4.463 1.96 ± 0.10
pacquet@main 4.327 ± 0.028 4.298 4.402 1.93 ± 0.09
pnpr@HEAD 2.300 ± 0.152 2.047 2.517 1.03 ± 0.08
pnpr@main 2.238 ± 0.107 2.094 2.363 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 4.39672875308,
      "stddev": 0.041539229738981505,
      "median": 4.39527598348,
      "user": 3.9353845599999993,
      "system": 3.5200066,
      "min": 4.34865101048,
      "max": 4.46314605348,
      "times": [
        4.34906919448,
        4.39353124748,
        4.46314605348,
        4.41565332848,
        4.40547193848,
        4.3662824994800005,
        4.39702071948,
        4.461932447480001,
        4.36652909148,
        4.34865101048
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 4.32713274788,
      "stddev": 0.02845407013933174,
      "median": 4.31925369098,
      "user": 3.8264943599999994,
      "system": 3.4955399999999996,
      "min": 4.29837698848,
      "max": 4.40220397748,
      "times": [
        4.32272167948,
        4.40220397748,
        4.33947160548,
        4.31626920048,
        4.31397163048,
        4.31176867548,
        4.3195337594800005,
        4.29837698848,
        4.31897362248,
        4.3280363394800005
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 2.29953341188,
      "stddev": 0.15178932155521838,
      "median": 2.3405453199800004,
      "user": 2.5611581599999997,
      "system": 3.0329577,
      "min": 2.04652392448,
      "max": 2.51719690448,
      "times": [
        2.3400748254800003,
        2.04652392448,
        2.36255983248,
        2.21136898648,
        2.1439140454800003,
        2.51719690448,
        2.34101581448,
        2.4708448454800003,
        2.3962452504800003,
        2.16558968948
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 2.23770367978,
      "stddev": 0.10656161862771524,
      "median": 2.23202003848,
      "user": 2.49941336,
      "system": 3.0072383999999994,
      "min": 2.09368173648,
      "max": 2.3632164284800004,
      "times": [
        2.33281539348,
        2.35658165948,
        2.09368173648,
        2.2714823124800003,
        2.3632164284800004,
        2.14625890248,
        2.14780365248,
        2.3433177934800002,
        2.19255776448,
        2.12932115448
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, hot cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 1.421 ± 0.015 1.400 1.453 2.06 ± 0.16
pacquet@main 1.416 ± 0.059 1.378 1.581 2.05 ± 0.18
pnpr@HEAD 0.691 ± 0.054 0.664 0.842 1.00
pnpr@main 0.713 ± 0.075 0.676 0.925 1.03 ± 0.14
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 1.4214510137800003,
      "stddev": 0.014596117327272676,
      "median": 1.41786725028,
      "user": 1.40448774,
      "system": 1.7496947200000001,
      "min": 1.40028705928,
      "max": 1.4525340912800002,
      "times": [
        1.4319441482800002,
        1.41646428828,
        1.42539496928,
        1.4189726482800002,
        1.4072351952800002,
        1.41676185228,
        1.4525340912800002,
        1.40028705928,
        1.41469349928,
        1.43022238628
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 1.4158289661799999,
      "stddev": 0.05926304805273192,
      "median": 1.4019274032800002,
      "user": 1.37192824,
      "system": 1.7428566199999995,
      "min": 1.3784998372800001,
      "max": 1.58057503928,
      "times": [
        1.40211349028,
        1.41607437628,
        1.58057503928,
        1.41104600028,
        1.40174131628,
        1.3784998372800001,
        1.3999243572800002,
        1.40408432128,
        1.38268120928,
        1.3815497142800002
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.69113171668,
      "stddev": 0.05350359304902866,
      "median": 0.6758226122800001,
      "user": 0.36366203999999996,
      "system": 1.30141822,
      "min": 0.66397956628,
      "max": 0.8424263322800001,
      "times": [
        0.68403718228,
        0.67871207128,
        0.68062320728,
        0.6768175362800001,
        0.66815096828,
        0.8424263322800001,
        0.66997654928,
        0.6748276882800001,
        0.66397956628,
        0.67176606528
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.71298844328,
      "stddev": 0.07528335046490357,
      "median": 0.6934628297800001,
      "user": 0.3579157399999999,
      "system": 1.31910652,
      "min": 0.67617994628,
      "max": 0.9253692382800001,
      "times": [
        0.67683168328,
        0.69563883228,
        0.6939688002800001,
        0.67848116828,
        0.69682369028,
        0.6929568592800001,
        0.67617994628,
        0.68678288528,
        0.9253692382800001,
        0.70685132928
      ]
    }
  ]
}

Scenario: Isolated linker: fresh install, cold cache + hot store

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 3.135 ± 0.037 3.101 3.228 4.63 ± 0.11
pacquet@main 3.137 ± 0.037 3.075 3.197 4.63 ± 0.11
pnpr@HEAD 0.689 ± 0.009 0.669 0.698 1.02 ± 0.02
pnpr@main 0.677 ± 0.014 0.667 0.715 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 3.1348341276,
      "stddev": 0.036591687395058844,
      "median": 3.1265023405,
      "user": 1.8723548200000004,
      "system": 2.04632758,
      "min": 3.101300715,
      "max": 3.228463255,
      "times": [
        3.110981959,
        3.113508394,
        3.11970871,
        3.149288592,
        3.101300715,
        3.1103388290000002,
        3.133295971,
        3.228463255,
        3.144359977,
        3.137094874
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 3.1373835094000007,
      "stddev": 0.03705731059946009,
      "median": 3.146552151,
      "user": 1.85845992,
      "system": 2.0621433799999997,
      "min": 3.074988383,
      "max": 3.196553503,
      "times": [
        3.1504931160000003,
        3.142611186,
        3.152474381,
        3.074988383,
        3.101046654,
        3.106207581,
        3.1512516010000002,
        3.196553503,
        3.178925882,
        3.119282807
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.6890683537000001,
      "stddev": 0.009213946688189964,
      "median": 0.6907891700000001,
      "user": 0.3725575199999999,
      "system": 1.30263678,
      "min": 0.6686400160000001,
      "max": 0.6983760470000001,
      "times": [
        0.6983760470000001,
        0.6686400160000001,
        0.693590727,
        0.684065797,
        0.6879876130000001,
        0.6945059950000001,
        0.697285086,
        0.684457913,
        0.6975400190000001,
        0.6842343240000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.6774310696000001,
      "stddev": 0.013634815111080154,
      "median": 0.6741047205000001,
      "user": 0.35523141999999996,
      "system": 1.27891808,
      "min": 0.6667327730000001,
      "max": 0.714709608,
      "times": [
        0.6737493360000001,
        0.6745258730000001,
        0.6714140670000001,
        0.6667327730000001,
        0.6716313130000001,
        0.6744601050000001,
        0.6706689880000001,
        0.714709608,
        0.6749359290000001,
        0.6814827040000001
      ]
    }
  ]
}

Scenario: Isolated linker: fresh resolve, hot cache, offline

Command Mean [ms] Min [ms] Max [ms] Relative
pacquet@HEAD 641.3 ± 13.7 620.9 662.4 5.94 ± 0.13
pacquet@main 646.3 ± 11.5 630.9 671.9 5.99 ± 0.11
pnpr@HEAD 107.9 ± 0.4 107.2 108.8 1.00
pnpr@main 108.1 ± 0.8 107.1 111.0 1.00 ± 0.01
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 0.6412950265600001,
      "stddev": 0.013679611066183268,
      "median": 0.64257943436,
      "user": 0.60832124,
      "system": 0.15315339999999997,
      "min": 0.6208866148600001,
      "max": 0.66241463686,
      "times": [
        0.6511668928600001,
        0.64097340386,
        0.63281497086,
        0.6334745968600001,
        0.6208866148600001,
        0.64817924786,
        0.6441854648600001,
        0.62317464286,
        0.66241463686,
        0.6556797938600001
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 0.6463403197600001,
      "stddev": 0.011485293825163825,
      "median": 0.64553973186,
      "user": 0.6116151399999998,
      "system": 0.15491090000000002,
      "min": 0.6309167188600001,
      "max": 0.6719146638600001,
      "times": [
        0.65069563586,
        0.6493007888600001,
        0.6370194398600001,
        0.6309167188600001,
        0.63731687286,
        0.64084854686,
        0.64699993986,
        0.6719146638600001,
        0.6543110668600001,
        0.6440795238600001
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 0.10787565030000001,
      "stddev": 0.00039773726133456684,
      "median": 0.10783611386,
      "user": 0.028375759999999993,
      "system": 0.018463399999999998,
      "min": 0.10724572486,
      "max": 0.10884308386,
      "times": [
        0.10761338886,
        0.10818965986,
        0.10852966886,
        0.10724572486,
        0.10772322286,
        0.10783611386,
        0.10780963386,
        0.10756648186000001,
        0.10756627186,
        0.10735331586,
        0.10858091986,
        0.10797308886,
        0.10805791486,
        0.10813131086,
        0.10769212286,
        0.10776549786,
        0.10787174386000001,
        0.10786372986000001,
        0.10729147086,
        0.10884308386,
        0.10750296886,
        0.10820046086,
        0.10796870586,
        0.10760331986,
        0.10811143586000001
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 0.10808226746000002,
      "stddev": 0.0008452411884849801,
      "median": 0.10784919386,
      "user": 0.026923239999999998,
      "system": 0.02023772,
      "min": 0.10708352486,
      "max": 0.11102403986,
      "times": [
        0.10720485086,
        0.10762743586,
        0.10833593286,
        0.10793779186,
        0.10871066886,
        0.10747249386,
        0.10773408786000001,
        0.10784919386,
        0.10784467986,
        0.10788387286000001,
        0.10800164086,
        0.10761088486,
        0.10828709186,
        0.10761396586000001,
        0.11014930286,
        0.11102403986,
        0.10847452086,
        0.10825894986000001,
        0.10708352486,
        0.10790404986,
        0.10770133786,
        0.10774293486,
        0.10797270286,
        0.10779694186,
        0.10783378886
      ]
    }
  ]
}

Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr

Command Mean [s] Min [s] Max [s] Relative
pacquet@HEAD 6.607 ± 0.178 6.392 6.891 1.34 ± 0.04
pacquet@main 6.646 ± 0.130 6.431 6.915 1.35 ± 0.03
pnpr@HEAD 5.099 ± 0.155 4.921 5.375 1.03 ± 0.03
pnpr@main 4.936 ± 0.034 4.872 5.000 1.00
BENCHMARK_REPORT.json
{
  "results": [
    {
      "command": "pacquet@HEAD",
      "mean": 6.606931111260001,
      "stddev": 0.17824769167790627,
      "median": 6.54487449526,
      "user": 3.8366802399999997,
      "system": 3.7320283599999997,
      "min": 6.39236242226,
      "max": 6.8905749502599996,
      "times": [
        6.77266895226,
        6.50874507826,
        6.49346448826,
        6.58465385026,
        6.58100391226,
        6.46055902326,
        6.88262258526,
        6.39236242226,
        6.50265585026,
        6.8905749502599996
      ]
    },
    {
      "command": "pacquet@main",
      "mean": 6.645925883560001,
      "stddev": 0.12973783708473993,
      "median": 6.614755821759999,
      "user": 3.8108048400000003,
      "system": 3.73750846,
      "min": 6.4314925682599995,
      "max": 6.91482651126,
      "times": [
        6.77726326926,
        6.608158825259999,
        6.60731228426,
        6.62135281826,
        6.4314925682599995,
        6.70364465626,
        6.592103607259999,
        6.91482651126,
        6.63517436426,
        6.56792993126
      ]
    },
    {
      "command": "pnpr@HEAD",
      "mean": 5.098751204859999,
      "stddev": 0.1550710111098305,
      "median": 5.09536845226,
      "user": 2.82800934,
      "system": 3.3029152600000002,
      "min": 4.92054080326,
      "max": 5.37518788426,
      "times": [
        4.92054080326,
        4.94451752026,
        5.19105544126,
        5.22723061526,
        5.030510309259999,
        5.37518788426,
        4.94022247626,
        4.9852904022599995,
        5.21273000126,
        5.16022659526
      ]
    },
    {
      "command": "pnpr@main",
      "mean": 4.936288956459999,
      "stddev": 0.03351037601367265,
      "median": 4.93439242926,
      "user": 2.78179964,
      "system": 3.28991156,
      "min": 4.87248298826,
      "max": 5.00020058226,
      "times": [
        4.93604011226,
        4.93269022526,
        4.95765336426,
        4.87248298826,
        4.9523900552599995,
        4.91433385626,
        5.00020058226,
        4.93274474626,
        4.95079813426,
        4.91355550026
      ]
    }
  ]
}

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12914
Testbedpacquet
Click to view all benchmark results
BenchmarkLatencyBenchmark Result
milliseconds (ms)
(Result Δ%)
Upper Boundary
milliseconds (ms)
(Limit %)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
🚷 view threshold
4,396.73 ms
(+3.33%)Baseline: 4,255.00 ms
5,106.00 ms
(86.11%)
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
🚷 view threshold
3,134.83 ms
(+3.42%)Baseline: 3,031.03 ms
3,637.23 ms
(86.19%)
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
🚷 view threshold
1,421.45 ms
(+4.85%)Baseline: 1,355.73 ms
1,626.87 ms
(87.37%)
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
🚷 view threshold
641.30 ms
(-1.03%)Baseline: 647.95 ms
777.54 ms
(82.48%)
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
🚷 view threshold
4,178.98 ms
(+2.03%)Baseline: 4,095.73 ms
4,914.88 ms
(85.03%)
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
🚷 view threshold
6,606.93 ms
(-4.49%)Baseline: 6,917.58 ms
8,301.10 ms
(79.59%)
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
🚷 view threshold
676.38 ms
(+6.68%)Baseline: 634.03 ms
760.83 ms
(88.90%)
🐰 View full continuous benchmarking report in Bencher

@github-actions

Copy link
Copy Markdown
Contributor

🐰 Bencher Report

Branchpr/12914
Testbedpnpr

⚠️ WARNING: No Threshold found!

Without a Threshold, no Alerts will ever be generated.

Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the --ci-only-thresholds flag.

Click to view all benchmark results
BenchmarkLatencymilliseconds (ms)
isolated-linker.fresh-install.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,299.53 ms
isolated-linker.fresh-install.cold-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
689.07 ms
isolated-linker.fresh-install.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
691.13 ms
isolated-linker.fresh-resolve.hot-cache.offline📈 view plot
⚠️ NO THRESHOLD
107.88 ms
isolated-linker.fresh-restore.cold-cache.cold-store📈 view plot
⚠️ NO THRESHOLD
2,146.02 ms
isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr📈 view plot
⚠️ NO THRESHOLD
5,098.75 ms
isolated-linker.fresh-restore.hot-cache.hot-store📈 view plot
⚠️ NO THRESHOLD
737.63 ms
🐰 View full continuous benchmarking report in Bencher

@zkochan
zkochan merged commit 2b02764 into main Jul 10, 2026
30 of 35 checks passed
@zkochan
zkochan deleted the pq-git-diff-filter branch July 10, 2026 18:12
eagarwal-notion added a commit to eagarwal-notion/pnpm that referenced this pull request Jul 10, 2026
pnpm installs a workspace whose root has no package.json with no root
importer and never creates one. pacquet's State::init scaffolded the
init-template package.json there instead, which diverges on disk and,
since the verify-deps-before-run gate started spawning an install
ahead of every run (pnpm#12910), poisoned recursive runs: the
scaffolded manifest carries npm's default failing test script, the
root joined the workspace graph as a selectable project, and a root
change (like pnpm-workspace.yaml) selected it — which is what broke
run_recursive's test_pattern_from_workspace_yaml_is_respected_by_the_test_script
on main after pnpm#12910 landed on top of pnpm#12914.

Inside a workspace the stand-in root manifest now stays in memory
only. Non-workspace installs keep scaffolding, and commands that save
the manifest (add) still persist it through their explicit save. The
remaining shape difference — pacquet still writes an empty root
importer to pnpm-lock.yaml where pnpm writes none — is a separate,
smaller parity gap.

Co-Authored-By: Claude Fable 5 <[email protected]>
zkochan pushed a commit to eagarwal-notion/pnpm that referenced this pull request Jul 10, 2026
pnpm's option parser accepts --if-present before the script
(`pnpm --workspace-concurrency=1 --no-sort --if-present .test`), but
pacquet's clap surface only declared it on the run/stop/restart
subcommands, so the top-level spelling failed to parse. This is the
exact shape of the repo's own test-pkgs-branch script, which every
pull-request TS CI job runs — together with the changed-packages
filter selector (pnpm#12914), this unblocks the ci:test-branch
job once a pnpm v12 alpha carrying both is released and the repo's
packageManager is bumped.

The flag is declared top-level like the other run-scoped options
(--resume-from, --report-summary, --no-bail) but deliberately not
clap-global: run/stop/restart declare their own --if-present, and a
propagated global flag would collide with theirs. Validation rejects
it for non-script commands the same way as the other run-scoped
flags, plus restart, which also runs scripts.

Co-Authored-By: Claude Fable 5 <[email protected]>
zkochan pushed a commit to eagarwal-notion/pnpm that referenced this pull request Jul 10, 2026
pnpm installs a workspace whose root has no package.json with no root
importer and never creates one. pacquet's State::init scaffolded the
init-template package.json there instead, which diverges on disk and,
since the verify-deps-before-run gate started spawning an install
ahead of every run (pnpm#12910), poisoned recursive runs: the
scaffolded manifest carries npm's default failing test script, the
root joined the workspace graph as a selectable project, and a root
change (like pnpm-workspace.yaml) selected it — which is what broke
run_recursive's test_pattern_from_workspace_yaml_is_respected_by_the_test_script
on main after pnpm#12910 landed on top of pnpm#12914.

Inside a workspace the stand-in root manifest now stays in memory
only. Non-workspace installs keep scaffolding, and commands that save
the manifest (add) still persist it through their explicit save. The
remaining shape difference — pacquet still writes an empty root
importer to pnpm-lock.yaml where pnpm writes none — is a separate,
smaller parity gap.

Co-Authored-By: Claude Fable 5 <[email protected]>
eagarwal-notion added a commit to eagarwal-notion/pnpm that referenced this pull request Jul 10, 2026
pnpm's option parser accepts --if-present before the script
(`pnpm --workspace-concurrency=1 --no-sort --if-present .test`), but
pacquet's clap surface only declared it on the run/stop/restart
subcommands, so the top-level spelling failed to parse. This is the
exact shape of the repo's own test-pkgs-branch script, which every
pull-request TS CI job runs — together with the changed-packages
filter selector (pnpm#12914), this unblocks the ci:test-branch
job once a pnpm v12 alpha carrying both is released and the repo's
packageManager is bumped.

The flag is declared top-level like the other run-scoped options
(--resume-from, --report-summary, --no-bail) but deliberately not
clap-global: run/stop/restart declare their own --if-present, and a
propagated global flag would collide with theirs. Validation rejects
it for non-script commands the same way as the other run-scoped
flags, plus restart, which also runs scripts.

Co-Authored-By: Claude Fable 5 <[email protected]>
eagarwal-notion added a commit to eagarwal-notion/pnpm that referenced this pull request Jul 10, 2026
pnpm installs a workspace whose root has no package.json with no root
importer and never creates one. pacquet's State::init scaffolded the
init-template package.json there instead, which diverges on disk and,
since the verify-deps-before-run gate started spawning an install
ahead of every run (pnpm#12910), poisoned recursive runs: the
scaffolded manifest carries npm's default failing test script, the
root joined the workspace graph as a selectable project, and a root
change (like pnpm-workspace.yaml) selected it — which is what broke
run_recursive's test_pattern_from_workspace_yaml_is_respected_by_the_test_script
on main after pnpm#12910 landed on top of pnpm#12914.

Inside a workspace the stand-in root manifest now stays in memory
only. Non-workspace installs keep scaffolding, and commands that save
the manifest (add) still persist it through their explicit save. The
remaining shape difference — pacquet still writes an empty root
importer to pnpm-lock.yaml where pnpm writes none — is a separate,
smaller parity gap.

Co-Authored-By: Claude Fable 5 <[email protected]>
eagarwal-notion added a commit to eagarwal-notion/pnpm that referenced this pull request Jul 10, 2026
pnpm installs a workspace whose root has no package.json with no root
importer and never creates one. pacquet's State::init scaffolded the
init-template package.json there instead, which diverges on disk and,
since the verify-deps-before-run gate started spawning an install
ahead of every run (pnpm#12910), poisoned recursive runs: the
scaffolded manifest carries npm's default failing test script, the
root joined the workspace graph as a selectable project, and a root
change (like pnpm-workspace.yaml) selected it — which is what broke
run_recursive's test_pattern_from_workspace_yaml_is_respected_by_the_test_script
on main after pnpm#12910 landed on top of pnpm#12914.

Inside a workspace the stand-in root manifest now stays in memory
only. Non-workspace installs keep scaffolding, and commands that save
the manifest (add) still persist it through their explicit save. The
remaining shape difference — pacquet still writes an empty root
importer to pnpm-lock.yaml where pnpm writes none — is a separate,
smaller parity gap.

Co-Authored-By: Claude Fable 5 <[email protected]>
zkochan added a commit that referenced this pull request Jul 10, 2026
…o pnpr (#12922)

Port `pnpm stage` (publish, list, view, approve, reject, download) to the
Rust CLI, mirroring the TypeScript command's flags, error codes, endpoints,
and output. `stage publish` reuses the publish pipeline (PublishArgs is
split into a reusable PublishFlags, and the pipeline returns summaries
instead of printing); approve/reject drive the shared OTP / web-auth flow;
download summarizes the tarball with the same traversal protections as
the TypeScript implementation. Also fixes the staged-publish route in
pacquet-publish to POST -/stage/package/:pkg (libnpmpublish's stage route)
instead of the regular packument PUT — previously unreachable because the
CLI hardcoded stage: false.

pnpr grows the server half: POST /-/stage/package/:pkg validates and
authorizes like a direct publish and holds the document under a UUID;
list/view/tarball inspect held records; approve replays the document
through the regular validate/stage/commit flow; reject deletes it. Records
persist under a reserved .staged/ namespace on the fs and S3 backends,
with stage-id validation ahead of any path or object key.

Shared plumbing: the capped response-body reader moves from the dist-tag
command into pacquet-network, and pacquet-pack exports its en-locale path
sort for the tarball summary.

Also fixes a broken test on main (semantic conflict between
#12910 and #12914): State::init no longer persists a
scaffolded root package.json when a pnpm-workspace.yaml sits next to the
missing manifest, so a verify-deps-before-run install can't turn the
workspace root into a selectable project with the init template's failing
test script.
zkochan pushed a commit to eagarwal-notion/pnpm that referenced this pull request Jul 10, 2026
pnpm's option parser accepts --if-present before the script
(`pnpm --workspace-concurrency=1 --no-sort --if-present .test`), but
pacquet's clap surface only declared it on the run/stop/restart
subcommands, so the top-level spelling failed to parse. This is the
exact shape of the repo's own test-pkgs-branch script, which every
pull-request TS CI job runs — together with the changed-packages
filter selector (pnpm#12914), this unblocks the ci:test-branch
job once a pnpm v12 alpha carrying both is released and the repo's
packageManager is bumped.

The flag is declared top-level like the other run-scoped options
(--resume-from, --report-summary, --no-bail) but deliberately not
clap-global: run/stop/restart declare their own --if-present, and a
propagated global flag would collide with theirs. Validation rejects
it for non-script commands the same way as the other run-scoped
flags, plus restart, which also runs scripts.

Co-Authored-By: Claude Fable 5 <[email protected]>
zkochan pushed a commit that referenced this pull request Jul 11, 2026
…caffolding a root manifest (#12919)

Accept --if-present ahead of the script name, the way pnpm's option
parser does. The repo's own test-pkgs-branch script uses that spelling,
so every PR TS CI job died at argument parsing under the pacquet-based
pnpm v12. Declared top-level like the other run-scoped options but not
clap-global (run/stop/restart declare their own --if-present), merged
with the subcommand flags, validated like --resume-from/--no-bail.
Rejected for exec like pnpm, where dispatch would drop it silently.

Never scaffold a missing manifest inside a workspace. Gate State::init's
no-scaffold path on workspace membership (config.workspace_dir) rather
than a pnpm-workspace.yaml beside the missing manifest, so installs in
workspace member directories can't scaffold a package.json either —
pnpm never creates one anywhere in a workspace. Keep an empty object as
the in-memory stand-in instead of the init template: pnpm's add at a
rootless workspace root persists a manifest holding only the added
dependencies, and the template's failing test script would otherwise
ride along on any explicit save.

Together with #12914 this unblocks the ci:test-branch job once
a pnpm v12 alpha carrying both is released and packageManager is bumped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet product: pnpm@11 reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants