feat: add bl git repo list/show commands#103
Conversation
📝 WalkthroughWalkthroughAdds Git repository support: new API models and client methods to fetch repositories, CLI commands Changes
Sequence Diagram(s)sequenceDiagram
participant CLI as CLI (bl)
participant Client as BacklogClient
participant API as Backlog API (HTTP)
CLI->>Client: call get_git_repositories(projectIdOrKey)
Client->>API: GET /api/v2/projects/{projectIdOrKey}/git/repositories
API-->>Client: 200 OK [JSON array of repositories]
Client->>Client: deserialize JSON -> Vec<GitRepository>
Client-->>CLI: return Vec<GitRepository>
CLI->>CLI: render text rows or pretty JSON
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
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 |
There was a problem hiding this comment.
Pull request overview
Adds first-class Git repository support to the bl CLI by implementing Backlog API v2 Git repository list/show endpoints and wiring them into the command tree, with docs updates for both EN and JA command references.
Changes:
- Introduce
src/api/git.rswithGitRepositorymodel andBacklogClientmethods for listing/showing Git repos. - Add
bl git repo listandbl git repo showcommands (including unit tests) and wire them intosrc/main.rs. - Update command documentation and command coverage tables in
website/docs/commands.mdand the Japanese translation.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| website/i18n/ja/docusaurus-plugin-content-docs/current/commands.md | Adds JA docs for bl git repo list/show and marks endpoints as implemented. |
| website/docs/commands.md | Adds EN docs for bl git repo list/show and marks endpoints as implemented. |
| src/main.rs | Adds clap subcommands for bl git repo list/show and dispatches to cmd::git. |
| src/cmd/mod.rs | Registers the new cmd::git module. |
| src/cmd/git/mod.rs | Adds cmd::git module exports for list/show. |
| src/cmd/git/list.rs | Implements bl git repo list command + tests. |
| src/cmd/git/show.rs | Implements bl git repo show command + tests. |
| src/api/mod.rs | Exposes api::git and extends BacklogApi trait + client impl. |
| src/api/git.rs | Adds Git API models + client methods + httpmock tests. |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/cmd/git/mod.rs (1)
1-5: Consider consolidating Git repo subcommands into a single resource file.This split works functionally, but it diverges from the repo’s established sub-resource layout and may increase navigation overhead over time.
♻️ Suggested module-level refactor
-mod list; -mod show; +mod repo; -pub use list::{GitRepoListArgs, list}; -pub use show::{GitRepoShowArgs, show}; +pub use repo::{GitRepoListArgs, GitRepoShowArgs, list, show};Based on learnings: “sub-resource command files under
src/cmd/<resource>/… should consolidate all subcommands … into a single file per resource. Do not split each subcommand into its own file.”🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/cmd/git/mod.rs` around lines 1 - 5, Currently git subcommands are split into separate modules (mod list; mod show;) with pub use of GitRepoListArgs/list and GitRepoShowArgs/show; consolidate them into a single resource module by merging the contents of the list and show modules into one file (e.g., the git resource module), replace the two mod declarations with a single module implementation, and re-export the unified symbols (keep the names GitRepoListArgs, list, GitRepoShowArgs, show) from that single module so callers do not need to change; remove the old separate module files and update any internal references to point to the consolidated module.src/cmd/git/list.rs (1)
41-43: Consider showing additional repository information.The current format only displays the repository name. For a list command, you might want to include the repository ID or HTTP URL to help users quickly identify and reference repositories for follow-up commands like
bl git repo show.💡 Optional: Include repo ID for easier reference
pub fn format_repo_row(repo: &GitRepository) -> String { - format!("{}", repo.name.cyan().bold()) + format!("{} (id: {})", repo.name.cyan().bold(), repo.id) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/cmd/git/list.rs` around lines 41 - 43, The current format_repo_row function only prints repo.name; update format_repo_row(&GitRepository) to include additional identifying info (e.g., repo.id and/or repo.http_url) alongside repo.name so list output is more actionable for follow-up commands; locate format_repo_row and the GitRepository fields (name, id, http_url) and change the formatted string to include the chosen identifier(s) (for example prefix with the repo id and append the http_url) while preserving existing styling (cyan().bold()) for the name.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/cmd/git/list.rs`:
- Around line 41-43: The current format_repo_row function only prints repo.name;
update format_repo_row(&GitRepository) to include additional identifying info
(e.g., repo.id and/or repo.http_url) alongside repo.name so list output is more
actionable for follow-up commands; locate format_repo_row and the GitRepository
fields (name, id, http_url) and change the formatted string to include the
chosen identifier(s) (for example prefix with the repo id and append the
http_url) while preserving existing styling (cyan().bold()) for the name.
In `@src/cmd/git/mod.rs`:
- Around line 1-5: Currently git subcommands are split into separate modules
(mod list; mod show;) with pub use of GitRepoListArgs/list and
GitRepoShowArgs/show; consolidate them into a single resource module by merging
the contents of the list and show modules into one file (e.g., the git resource
module), replace the two mod declarations with a single module implementation,
and re-export the unified symbols (keep the names GitRepoListArgs, list,
GitRepoShowArgs, show) from that single module so callers do not need to change;
remove the old separate module files and update any internal references to point
to the consolidated module.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 44c1a8d0-1997-46fa-8957-51614d2a1d56
📒 Files selected for processing (9)
src/api/git.rssrc/api/mod.rssrc/cmd/git/list.rssrc/cmd/git/mod.rssrc/cmd/git/show.rssrc/cmd/mod.rssrc/main.rswebsite/docs/commands.mdwebsite/i18n/ja/docusaurus-plugin-content-docs/current/commands.md
Addresses review comment: deserialize drops the raw JSON payload
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/api/git.rs (1)
52-69: Optional: URL-encode path parameters for consistency with defensive programming practices.Path parameters (
project_id_or_key,repo_id_or_name) are interpolated directly into URLs. While the Backlog API likely restricts allowed characters in these identifiers, URL-encoding would add robustness against unexpected input. Note: This pattern is consistent across all other API methods in the codebase (e.g.,user.rs,project.rs,team.rs,wiki.rs), so any change should apply codebase-wide rather than to these methods alone.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/api/git.rs` around lines 52 - 69, The get methods on BacklogClient (get_git_repositories and get_git_repository) currently interpolate project_id_or_key and repo_id_or_name directly into the request path; update both methods to URL-encode those path parameters before formatting the path (e.g., encode project_id_or_key and repo_id_or_name with a safe URL-encoding helper) and use the encoded values in the format! call; apply the same change consistently to other API methods that build paths from identifiers (e.g., functions in user.rs, project.rs, team.rs, wiki.rs) so all path parameters are defensively URL-encoded before calling self.get.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/api/git.rs`:
- Around line 52-69: The get methods on BacklogClient (get_git_repositories and
get_git_repository) currently interpolate project_id_or_key and repo_id_or_name
directly into the request path; update both methods to URL-encode those path
parameters before formatting the path (e.g., encode project_id_or_key and
repo_id_or_name with a safe URL-encoding helper) and use the encoded values in
the format! call; apply the same change consistently to other API methods that
build paths from identifiers (e.g., functions in user.rs, project.rs, team.rs,
wiki.rs) so all path parameters are defensively URL-encoded before calling
self.get.
Checklist
mainwebsite/docs/,website/i18n/ja/,README.md)Summary
bl git repo list <project-id-or-key>— lists Git repositories in a projectbl git repo show <project-id-or-key> <repo-id-or-name>— shows details of a Git repositoryReason for change
Implements #50.
Changes
src/api/git.rs—GitRepositorystruct +BacklogClientmethods for both endpointssrc/api/mod.rs— trait declaration + implsrc/cmd/git/list.rs,src/cmd/git/show.rs— command logic with testssrc/cmd/git/mod.rs— re-exportssrc/cmd/mod.rs— addedgitmodulesrc/main.rs— clap wiring forbl git repo list/showwebsite/docs/commands.md,website/i18n/ja/.../commands.md— docs and coverage table updatedNotes
Closes #50