Skip to content

📝 CodeRabbit Chat: Implement requested code changes - #77

Open
coderabbitai[bot] wants to merge 2 commits into
mainfrom
coderabbitai/chat/40ef293
Open

📝 CodeRabbit Chat: Implement requested code changes#77
coderabbitai[bot] wants to merge 2 commits into
mainfrom
coderabbitai/chat/40ef293

Conversation

@coderabbitai

@coderabbitai coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Code changes was requested by @leynos.

The following files were modified:

  • lading/commands/lockfile.py

Summary by Sourcery

Refine discovery of tracked Cargo.lock files by delegating git querying and manifest filtering to helper functions and adding safeguards for non-git workspaces or missing lockfiles.

Enhancements:

  • Introduce a helper to run git ls-files for Cargo.lock discovery with clearer logging on failure and non-git repositories.
  • Add a helper to filter discovered lockfiles to those with adjacent Cargo.toml manifests.
  • Short-circuit lockfile discovery when no Cargo.lock files are present in the workspace tree.

leynos and others added 2 commits June 1, 2026 23:20
Add tracked `Cargo.lock` discovery and refresh support after manifest
version rewrites so nested workspace lockfiles stay aligned with bumped
path dependency versions.

Validate tracked lockfiles before publish preflight cargo checks and
report stale files with the exact `cargo generate-lockfile` repair
command. Cover the behaviour with unit and BDD tests for live bump,
dry-run bump, and publish preflight failures.
@coderabbitai
coderabbitai Bot requested a review from leynos June 5, 2026 20:37
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown
Author

Important

Review skipped

This PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 86106991-6739-43c4-90ed-18a0214c97e3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@sourcery-ai

sourcery-ai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

Refactors Cargo.lock discovery to always use git ls-files output when lockfiles exist, adding helpers to query git and filter for lockfiles with adjacent manifests while improving error handling and logging around non‑git and failure scenarios.

Sequence diagram for updated discover_tracked_lockfiles flow

sequenceDiagram
    participant Caller
    participant discover_tracked_lockfiles
    participant _query_git_tracked_lockfiles
    participant runner
    participant _filter_lockfiles_with_manifests
    participant LOGGER

    Caller->>discover_tracked_lockfiles: discover_tracked_lockfiles(workspace_root, runner)
    discover_tracked_lockfiles->>discover_tracked_lockfiles: workspace_root.rglob("Cargo.lock")
    discover_tracked_lockfiles-->>Caller: () [no lockfiles]
    opt [at least one Cargo.lock]
        discover_tracked_lockfiles->>_query_git_tracked_lockfiles: _query_git_tracked_lockfiles(workspace_root, runner)
        _query_git_tracked_lockfiles->>runner: runner(("git","ls-files","*/Cargo.lock","Cargo.lock"), cwd=workspace_root)
        runner-->>_query_git_tracked_lockfiles: exit_code, stdout, stderr
        alt [exit_code == 0]
            _query_git_tracked_lockfiles-->>discover_tracked_lockfiles: stdout
        else [exit_code != 0]
            alt ["not a git repository" in detail]
                _query_git_tracked_lockfiles->>LOGGER: warning("Skipping Cargo.lock discovery because ... is not a git repository")
            else
                _query_git_tracked_lockfiles->>LOGGER: warning("Skipping Cargo.lock discovery after git ls-files failed: %s", detail)
            end
            _query_git_tracked_lockfiles-->>discover_tracked_lockfiles: None
        end
        alt [stdout is None]
            discover_tracked_lockfiles-->>Caller: ()
        else [stdout is not None]
            discover_tracked_lockfiles->>_filter_lockfiles_with_manifests: _filter_lockfiles_with_manifests(workspace_root, stdout)
            _filter_lockfiles_with_manifests-->>discover_tracked_lockfiles: tuple[Path,...]
            discover_tracked_lockfiles-->>Caller: tuple[Path,...]
        end
    end
Loading

File-Level Changes

Change Details Files
Refactor lockfile discovery into smaller helpers that gate on the presence of lockfiles and rely on git ls-files output, with clearer error handling.
  • Introduce _query_git_tracked_lockfiles to run git ls-files and return stdout or None while logging specific warnings for non-git repositories and other failures.
  • Introduce _filter_lockfiles_with_manifests to parse git ls-files output, build absolute paths, and keep only lockfiles that have an adjacent Cargo.toml.
  • Update discover_tracked_lockfiles to first check for any non-target Cargo.lock via rglob, then call _query_git_tracked_lockfiles and _filter_lockfiles_with_manifests, returning an empty tuple when no lockfiles are present or git querying fails.
  • Remove the old direct rglob-based collection in discover_tracked_lockfiles that did not use git ls-files.
  • Adjust the refresh_lockfile signature formatting without changing its behavior.
lading/commands/lockfile.py

Possibly linked issues

  • #N/A: PR updates tracked Cargo.lock discovery, directly contributing to the issue’s requested lockfile refresh/validation behavior.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • In discover_tracked_lockfiles, you're walking the tree with rglob("Cargo.lock") only to compute has_lockfiles; consider reusing the discovered paths (e.g., store them in a tuple and use it for the early-empty check) to avoid a redundant filesystem walk if you later need those paths for other work.
  • The refresh_lockfile function no longer has a -> Path return annotation but its docstring still says it returns the lockfile path; align the type hint and docstring with the actual behavior for consistency.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `discover_tracked_lockfiles`, you're walking the tree with `rglob("Cargo.lock")` only to compute `has_lockfiles`; consider reusing the discovered paths (e.g., store them in a tuple and use it for the early-empty check) to avoid a redundant filesystem walk if you later need those paths for other work.
- The `refresh_lockfile` function no longer has a `-> Path` return annotation but its docstring still says it returns the lockfile path; align the type hint and docstring with the actual behavior for consistency.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@lodyai
lodyai Bot force-pushed the issue-61-refresh-stale-nested-cargo-lock-files-before-publish-preflight branch from cfaa044 to 527c7a8 Compare June 8, 2026 17:56
Base automatically changed from issue-61-refresh-stale-nested-cargo-lock-files-before-publish-preflight to main June 8, 2026 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant