Surface lockfile discovery failures via typed exceptions (#79) - #131
Surface lockfile discovery failures via typed exceptions (#79)#131leynos wants to merge 1 commit into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Reviewer's GuideRefactors lockfile discovery to surface non-git workspaces via a typed exception instead of a silent skip, moves the skip policy to the publish preflight caller, and adds integration and unit tests that exercise discovery against real git repositories and assert the new error-handling behavior. Sequence diagram for lockfile discovery error propagation and skip policysequenceDiagram
participant PublishPreflight
participant discover_tracked_lockfiles
participant runner
participant _raise_git_ls_files_failure
PublishPreflight->>discover_tracked_lockfiles: discover_tracked_lockfiles(workspace_root, runner_with_env)
discover_tracked_lockfiles->>runner: runner(("git", "ls-files", "**/Cargo.lock", "Cargo.lock"), cwd=workspace_root)
runner-->>discover_tracked_lockfiles: exit_code, stdout, stderr
alt exit_code != 0
discover_tracked_lockfiles->>_raise_git_ls_files_failure: _raise_git_ls_files_failure(exit_code, stdout, stderr, workspace_root)
alt ["not a git repository" in detail]
_raise_git_ls_files_failure-->>PublishPreflight: raise NotAGitRepositoryError
PublishPreflight->>PublishPreflight: LOGGER.warning("Skipping lockfile freshness validation...")
PublishPreflight-->>PublishPreflight: return
else other git failure
_raise_git_ls_files_failure-->>PublishPreflight: raise LockfileDiscoveryError
end
else exit_code == 0
discover_tracked_lockfiles-->>PublishPreflight: tracked_lockfiles
end
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
3739c1e to
c6ad97d
Compare
discover_tracked_lockfiles hid a non-git workspace behind a warning and a silent empty tuple, so callers could not distinguish "no tracked lockfiles" from "discovery never ran". Filesystem access was also mixed into the function rather than confined to a port. Raise a typed NotAGitRepositoryError (subclass of LockfileDiscoveryError) for non-git workspaces and keep LockfileDiscoveryError for other git failures. The skip policy moves to the caller: publish pre-flight catches NotAGitRepositoryError, warns, and continues, preserving existing operator behaviour while making the condition explicit at the API. Filesystem access is now documented as confined to the injected manifest_exists port and git access to the injected runner; the function performs no direct I/O of its own. Replace the silent-skip unit test with a typed-exception assertion, add a caller-policy test for the pre-flight skip, and add integration tests that exercise discovery against real git repositories in temporary directories through the real subprocess runner (tracked versus untracked lockfiles, target/ exclusion, manifest adjacency, and the non-git error). Closes #79
c6ad97d to
f3ce412
Compare
Summary
Closes #79
discover_tracked_lockfilespreviously hid a non-git workspace behind a warning and a silent empty tuple. It now raises a typedNotAGitRepositoryError(subclass ofLockfileDiscoveryError) for non-git workspaces; other git failures keep raisingLockfileDiscoveryError.NotAGitRepositoryError, warns, and continues — preserving operator behaviour while making the condition explicit at the API.runner, filesystem access through the injectedmanifest_existsadapter; the function performs no direct I/O of its own (documented in the docstring).Testing
tests/integration/test_lockfile_discovery.pyexercises discovery against real git repositories in temporary directories through the real subprocess runner, without stubbing internals: tracked vs untracked lockfiles,target/exclusion, manifest adjacency, and the non-git typed error.make check-fmt,make lint,make typecheck, andmake test(565 passed) all green after rebasing onto currentmain.coderabbit review --agent: 0 findings.🤖 Generated with Claude Code
Summary by Sourcery
Surface non-git workspaces as typed errors during Cargo.lock discovery and delegate skip policy to the publish pre-flight caller.
New Features:
Bug Fixes:
Enhancements:
Tests:
References