Conversation
Reviewer's GuideAdds git/SSH-based upstream configuration fetching via a new fetch_upstream_config helper that performs an efficient shallow git clone for non-HTTP URLs, wires it into the check and pull commands, ensures raw URL resolution bypasses git/SSH URLs, updates CLI help and README usage docs, and adds tests covering git clone behavior and URL handling. Sequence diagram for the new fetch_upstream_config retrieval flowsequenceDiagram
actor User
participant RuffSyncCLI
participant fetch_upstream_config
participant GitSubprocess
participant GitRemote
participant HttpServer
User->>RuffSyncCLI: run check/pull with upstream URL
RuffSyncCLI->>fetch_upstream_config: url, client, branch, path
alt URL is ssh/git/git+ssh or starts with git@
fetch_upstream_config->>GitSubprocess: git clone --depth 1 --filter=blob:none --no-checkout --branch branch url
GitSubprocess->>GitRemote: shallow clone metadata
GitRemote-->>GitSubprocess: repo metadata
GitSubprocess-->>fetch_upstream_config: clone completed
fetch_upstream_config->>GitSubprocess: git -C temp_dir restore --source branch target_path
GitSubprocess->>GitRemote: fetch pyproject.toml blob
GitRemote-->>GitSubprocess: pyproject.toml contents
GitSubprocess-->>fetch_upstream_config: file materialized in temp_dir
fetch_upstream_config-->>RuffSyncCLI: StringIO(pyproject.toml from git)
else URL is http/https
fetch_upstream_config->>HttpServer: HTTP GET resolved raw URL
HttpServer-->>fetch_upstream_config: pyproject.toml response text
fetch_upstream_config-->>RuffSyncCLI: StringIO(pyproject.toml from http)
end
RuffSyncCLI->>RuffSyncCLI: get_ruff_tool_table and merge/check
RuffSyncCLI-->>User: result of pull/check
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #78 +/- ##
==========================================
- Coverage 92.83% 92.13% -0.71%
==========================================
Files 1 1
Lines 321 356 +35
==========================================
+ Hits 298 328 +30
- Misses 23 28 +5 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've found 1 issue, and left some high level feedback:
- The logic for detecting git/SSH URLs (
url.schemechecks plusstr(url).startswith('git@')) is duplicated in bothresolve_raw_urlandfetch_upstream_config; consider extracting this into a small helper (e.g.,is_git_url(url)) to keep the behavior consistent and easier to update. - Relying on
git restoreassumes a relatively recent git version; if you need broader compatibility, consider falling back togit checkoutor similar whenrestoreis not available.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The logic for detecting git/SSH URLs (`url.scheme` checks plus `str(url).startswith('git@')`) is duplicated in both `resolve_raw_url` and `fetch_upstream_config`; consider extracting this into a small helper (e.g., `is_git_url(url)`) to keep the behavior consistent and easier to update.
- Relying on `git restore` assumes a relatively recent git version; if you need broader compatibility, consider falling back to `git checkout` or similar when `restore` is not available.
## Individual Comments
### Comment 1
<location path="tests/test_git_fetch.py" line_range="12-21" />
<code_context>
+ assert restore_args[6] == "sub/dir/pyproject.toml"
+
+
+@pytest.mark.asyncio
+async def test_fetch_upstream_config_git_failure(monkeypatch: pytest.MonkeyPatch):
+ url = URL("git@github.com:Kilo59/ruff-sync.git")
+
</code_context>
<issue_to_address>
**suggestion (testing):** Add a test for the FileNotFoundError path when pyproject.toml is missing after a successful git operation.
The code now explicitly raises `FileNotFoundError` when git operations succeed but `pyproject.toml` is missing. Currently, only the `CalledProcessError` path is tested. Please add a test that mocks successful `subprocess.run` calls (clone and restore both returning zero) without creating the config file, and asserts that `fetch_upstream_config` raises `FileNotFoundError` to cover this error path.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
Summary by Sourcery
Add support for fetching upstream configuration via git clone for SSH/git URLs while preserving existing HTTP-based fetching.
New Features:
Enhancements:
Documentation:
Tests:
CI Improvements:
pre-publishjob that builds the package and verifies it installs correctly viauv tool installin a clean environment before publishing to PyPI.Script Capabilities:
pull_dogfood.shandcheck_dogfood.sh).gitclone_dogfood.shscript to exercise the tool's new git-fetching behavior locally.