Skip to content

refactor(fetcher): rename project_name/project → git_repo_name/github_repo - #93

Merged
unhappychoice merged 2 commits into
mainfrom
refactor/rename-project-fetchers
Apr 23, 2026
Merged

unhappychoice merged 2 commits into
mainfrom
refactor/rename-project-fetchers

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Apr 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • project_name → git_repo_name (moved to src/fetcher/git/repo_name.rs, struct GitRepoName) — reads the git remote via gix, falls back to the cwd basename.
  • project → github_repo (moved to src/fetcher/github/repo.rs, struct GithubRepo) — hits the GitHub REST API /repos/{o}/{n} for the { slug, description, license } triple.
  • The project prefix didn't reflect what these fetchers do; the names now match their namespace (git/ vs github/) and their underlying source.
  • Template project_github_activity.toml and the derive_shape test in runtime.rs follow the new names.

Refs #81 (0.x release scope, DoD ticks for both fetchers).

Test plan

  • cargo build --all-targets
  • cargo clippy --all-targets -- -D warnings
  • cargo fmt --all -- --check
  • cargo test — rename-specific tests pass; the 2 pre-existing template failures ("static" vs "basic_static") reproduce on main and are unrelated.
  • cargo xtask — docs regen produces git_repo_name.md / github_repo.md, stale project*.md removed.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added Git repository name detection that automatically identifies the repository name from git remotes or the current directory.
    • Added GitHub repository fetcher for enhanced GitHub project data retrieval.
  • Refactor

    • Consolidated repository fetching logic and removed legacy project fetcher implementation.

@coderabbitai

coderabbitai Bot commented Apr 23, 2026 •

Copy link
Copy Markdown

Warning

Rate limit exceeded

@unhappychoice has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 58 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dbbe4066-1c87-49bb-b58c-a3bfb6196281

📥 Commits

Reviewing files that changed from the base of the PR and between 0b531e3 and 6a11734.

📒 Files selected for processing (11)
  • .splashboard/dashboard.toml
  • docs-site/src/content/docs/guides/concepts.md
  • docs-site/src/content/docs/guides/configuration.md
  • docs-site/src/content/docs/guides/presets.mdx
  • src/fetcher/git/mod.rs
  • src/fetcher/git/repo_name.rs
  • src/fetcher/github/mod.rs
  • src/fetcher/github/repo.rs
  • src/fetcher/mod.rs
  • src/runtime.rs
  • src/templates/project_github_activity.toml
📝 Walkthrough

Walkthrough

The PR consolidates repository fetchers by introducing a GitRepoName fetcher that detects local git repository names from remotes, and refactoring GitHub's separate ProjectName and Project fetchers into a single GithubRepo fetcher. The orphaned project module is removed from the registry, and the template is updated to reference the new fetcher names.

Changes

Cohort / File(s) Summary
Git Fetcher Addition
src/fetcher/git/mod.rs, src/fetcher/git/repo_name.rs
Adds new GitRepoName fetcher that detects repository display name by discovering git remotes in the current directory, parsing the fetch URL into owner/name slug format, with fallback to the current directory name. Includes unit test for sample body non-emptiness.
GitHub Fetcher Consolidation
src/fetcher/github/mod.rs, src/fetcher/github/repo.rs
Merges separate ProjectName and Project fetchers into single GithubRepo fetcher; removes local git remote detection logic previously in ProjectName; updates tests and sample body targeting.
Registry Cleanup
src/fetcher/mod.rs
Removes unused project module export and de-registers project::ProjectName and project::Project fetchers from builtin registry.
Template & Test Updates
src/templates/project_github_activity.toml, src/runtime.rs
Updates dashboard template hero widget to use git_repo_name instead of project_name, and subtitle widget to use github_repo instead of project; updates corresponding unit test to reference new fetcher identifier.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

  • PR #88: Adds GithubAvatar fetcher registration to src/fetcher/github/mod.rs, directly paralleling this PR's GitHub fetcher registration pattern.
  • PR #28: Modifies fetcher registry and module structure, sharing the same registry/configuration refactoring scope as this PR.
  • PR #54: Extends fetcher trait implementations and sample-body generation plumbing that directly enables the new GitRepoName fetcher's design.

Poem

🐰 A warren of fetchers, once scattered and wide,
Now organized snug in a burrow with pride—
Git finds its own way through remotes and URLs bright,
While GitHub repos nestle in unified light. 🌙✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically summarizes the main refactoring: renaming two fetcher types from project_name/project to git_repo_name/github_repo, which is the core change across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/rename-project-fetchers

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.

❤️ Share

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

…_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]>
@unhappychoice
unhappychoice force-pushed the refactor/rename-project-fetchers branch from 0b531e3 to 35e2b81 Compare April 23, 2026 22:16
@codecov

codecov Bot commented Apr 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 53.19149% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.81%. Comparing base (3f313d6) to head (6a11734).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/fetcher/git/repo_name.rs 46.34% 22 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
src/fetcher/git/mod.rs 56.00% <100.00%> (+0.89%) ⬆️
src/fetcher/github/mod.rs 100.00% <100.00%> (ø)
src/fetcher/github/repo.rs 66.43% <100.00%> (ø)
src/fetcher/mod.rs 77.91% <ø> (-0.18%) ⬇️
src/runtime.rs 78.57% <100.00%> (ø)
src/fetcher/git/repo_name.rs 46.34% <46.34%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai 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.

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_key omits shape — two github_repo widgets with different shapes can collide.

cwd_scoped hashes only the current directory, but fetch produces different Body variants (Entries / TextBlock / Text) per ctx.shape. Two widgets configured with the same github_repo fetcher but different renderers will share a cache entry: the first fetch wins (the other skips via try_lock), and load_entries hands both widget ids the same cached body — whose shape won't match one of them. Git fetchers already avoid this via repo_cache_key, which mixes ctx.shape/ctx.format into the hash.

The default template only uses github_repo once, 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_name and github_repo both 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 the project prefix 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

📥 Commits

Reviewing files that changed from the base of the PR and between 3f313d6 and 0b531e3.

📒 Files selected for processing (7)
  • src/fetcher/git/mod.rs
  • src/fetcher/git/repo_name.rs
  • src/fetcher/github/mod.rs
  • src/fetcher/github/repo.rs
  • src/fetcher/mod.rs
  • src/runtime.rs
  • src/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]>
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