Skip to content

Eliminate redundant rglob I/O pass in discover_tracked_lockfiles #83

Description

@coderabbitai

Background

Raised during review of PR #75 (refresh stale Cargo lockfiles before publish preflight).

Problem

discover_tracked_lockfiles currently performs three sequential I/O operations:

  1. workspace_root.rglob("Cargo.lock") — filesystem walk to find candidate lockfiles
  2. git ls-files — subprocess call to narrow to tracked files
  3. (lockfile_path.parent / "Cargo.toml").exists() — per-file existence check

The first pass (rglob) is redundant because git ls-files already enumerates tracked lockfiles. Removing it reduces I/O, eliminates the early-exit guard on empty candidates, and simplifies the function.

Similarly, validate_lockfile_freshness spawns one cargo metadata process per lockfile; consider early-exit on the first stale lockfile to avoid unnecessary subprocess invocations when the caller will abort on any stale result.

Resolution

  • Replace rglob with direct reliance on git ls-files output in discover_tracked_lockfiles; keep only the target/ filter and Cargo.toml adjacency check.
  • Evaluate whether _validate_lockfile_freshness in publish_preflight.py should short-circuit after the first stale lockfile.
  • Update unit tests to reflect the simpler discovery path.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions