Repository navigation
refactor(fetcher): rename project_name/project → git_repo_name/github_repo - #93
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 58 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThe PR consolidates repository fetchers by introducing a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
…_repo The `project` prefix didn't reflect what these fetchers actually do: `project_name` reads the git remote (gix), and `project` hits the GitHub REST API. Move them into the matching subdirectories and rename to `git_repo_name` / `github_repo` so the names match their namespace. - `src/fetcher/git/repo_name.rs` (GitRepoName) - `src/fetcher/github/repo.rs` (GithubRepo) - Template `project_github_activity.toml` and the `derive_shape` test follow the new names. Refs #81. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
0b531e3 to
35e2b81
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #93 +/- ##
==========================================
+ Coverage 78.80% 78.81% +0.01%
==========================================
Files 81 82 +1
Lines 12904 12902 -2
==========================================
Hits 10169 10169
+ Misses 2735 2733 -2
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/fetcher/github/repo.rs (1)
34-36:⚠️ Potential issue | 🟡 Minor
cache_keyomits shape — twogithub_repowidgets with different shapes can collide.
cwd_scopedhashes only the current directory, butfetchproduces differentBodyvariants (Entries/TextBlock/Text) perctx.shape. Two widgets configured with the samegithub_repofetcher but different renderers will share a cache entry: the first fetch wins (the other skips viatry_lock), andload_entrieshands both widget ids the same cached body — whose shape won't match one of them. Git fetchers already avoid this viarepo_cache_key, which mixesctx.shape/ctx.formatinto the hash.The default template only uses
github_repoonce, so this doesn't bite today — but it's a footgun for anyone reusing the fetcher.🛠️ Suggested fix: mix shape (and format) into the key
fn cache_key(&self, _ctx: &FetchContext) -> String { - cwd_scoped(self.name()) + cwd_scoped(self.name(), _ctx) } @@ -fn cwd_scoped(name: &str) -> String { - let cwd: PathBuf = std::env::current_dir().unwrap_or_default(); - let digest = Sha256::digest(cwd.to_string_lossy().as_bytes()); - let hex: String = digest.iter().take(8).map(|b| format!("{b:02x}")).collect(); - format!("{name}-{hex}") -} +fn cwd_scoped(name: &str, ctx: &FetchContext) -> String { + let cwd: PathBuf = std::env::current_dir().unwrap_or_default(); + let shape = ctx.shape.map(|s| s.as_str()).unwrap_or("default"); + let raw = format!( + "{}|{}|{}|{}", + name, + cwd.to_string_lossy(), + shape, + ctx.format.as_deref().unwrap_or(""), + ); + let digest = Sha256::digest(raw.as_bytes()); + let hex: String = digest.iter().take(8).map(|b| format!("{b:02x}")).collect(); + format!("{name}-{hex}") +}Also applies to: 141-146
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/fetcher/github/repo.rs` around lines 34 - 36, cache_key currently returns cwd_scoped(self.name()) which ignores the request shape/format and can cause two github_repo fetches with different ctx.shape/ctx.format to collide; update cache_key in src/fetcher/github/repo.rs (and the analogous key-generation at lines ~141-146) to include ctx.shape and ctx.format (or call the existing repo_cache_key helper used by git fetchers) so the cache key mixes the fetch context shape/format with the repo name, preventing shape-mismatched cache hits.
🧹 Nitpick comments (1)
src/templates/project_github_activity.toml (1)
1-25: Template fetcher references align with the new registry identifiers.
git_repo_nameandgithub_repoboth resolve to registered fetchers, and the inline comments are in sync with the new shape sources.Optional nit: the PR description mentions renaming the template, but the file is still
project_github_activity.toml. If the intent is to drop theprojectprefix everywhere, consider renaming the file (and any docs/examples that link to it) in a follow-up. Not a blocker.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/templates/project_github_activity.toml` around lines 1 - 25, The template uses the new registry fetcher identifiers but the file still uses the old `project_` prefix; confirm that the fetcher names referenced in widget id "hero" (`fetcher = "git_repo_name"`) and widget id "subtitle" (`fetcher = "github_repo"`) are correct in the registry and update any references if they changed, and if the intended rename was to remove the `project_` prefix rename this file and any docs/examples that link to `project_github_activity.toml` to the new name so examples and CI/docs remain consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@src/fetcher/github/repo.rs`:
- Around line 34-36: cache_key currently returns cwd_scoped(self.name()) which
ignores the request shape/format and can cause two github_repo fetches with
different ctx.shape/ctx.format to collide; update cache_key in
src/fetcher/github/repo.rs (and the analogous key-generation at lines ~141-146)
to include ctx.shape and ctx.format (or call the existing repo_cache_key helper
used by git fetchers) so the cache key mixes the fetch context shape/format with
the repo name, preventing shape-mismatched cache hits.
---
Nitpick comments:
In `@src/templates/project_github_activity.toml`:
- Around line 1-25: The template uses the new registry fetcher identifiers but
the file still uses the old `project_` prefix; confirm that the fetcher names
referenced in widget id "hero" (`fetcher = "git_repo_name"`) and widget id
"subtitle" (`fetcher = "github_repo"`) are correct in the registry and update
any references if they changed, and if the intended rename was to remove the
`project_` prefix rename this file and any docs/examples that link to
`project_github_activity.toml` to the new name so examples and CI/docs remain
consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7198d596-682c-480b-9dc4-f151913bf21b
📒 Files selected for processing (7)
src/fetcher/git/mod.rssrc/fetcher/git/repo_name.rssrc/fetcher/github/mod.rssrc/fetcher/github/repo.rssrc/fetcher/mod.rssrc/runtime.rssrc/templates/project_github_activity.toml
💤 Files with no reviewable changes (1)
- src/fetcher/mod.rs
…uides Missed call sites from the previous refactor — the repo's own `.splashboard/dashboard.toml` and three hand-written guide pages still referenced `project_name` / `project`, which rendered as "unknown fetcher" placeholders when anyone cd'd into the repo. Switch them to `git_repo_name` / `github_repo`. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Summary
project_name→git_repo_name(moved tosrc/fetcher/git/repo_name.rs, structGitRepoName) — reads the git remote viagix, falls back to the cwd basename.project→github_repo(moved tosrc/fetcher/github/repo.rs, structGithubRepo) — hits the GitHub REST API/repos/{o}/{n}for the{ slug, description, license }triple.projectprefix didn't reflect what these fetchers do; the names now match their namespace (git/ vs github/) and their underlying source.project_github_activity.tomland thederive_shapetest inruntime.rsfollow the new names.Refs #81 (0.x release scope, DoD ticks for both fetchers).
Test plan
cargo build --all-targetscargo clippy --all-targets -- -D warningscargo fmt --all -- --checkcargo test— rename-specific tests pass; the 2 pre-existing template failures ("static"vs"basic_static") reproduce onmainand are unrelated.cargo xtask— docs regen producesgit_repo_name.md/github_repo.md, staleproject*.mdremoved.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Refactor