feat: gh pr create/merge/diff/comment/edit + gh api#31
feat: gh pr create/merge/diff/comment/edit + gh api#31pszymkowiak merged 4 commits intortk-ai:masterfrom
Conversation
- Make compact_diff pub(crate) in git.rs for cross-module use - Extract filter_json_string() from json_cmd.rs for reuse - Add ok_confirmation() to utils.rs for write operation confirmations - Add detect_package_manager() and package_manager_exec() to utils.rs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- cargo build: strip Compiling/Downloading lines, show errors + summary - cargo test: show failures only + summary line - cargo clippy: group warnings by lint rule with locations New module: src/cargo_cmd.rs with 6 unit tests Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- git branch: compact listing (current/local/remote-only) - git fetch: "ok fetched (N new refs)" confirmation - git stash: list/show/pop/apply/drop with compact output - git worktree: compact listing with home dir abbreviation 4 new tests in git.rs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- gh pr create: capture URL + number, "ok created #N url"
- gh pr merge: "ok merged #N" confirmation
- gh pr diff: reuse compact_diff() for condensed output
- gh pr comment/edit: generic "ok {action} #N" confirmations
- gh api: auto-detect JSON, pipe through filter_json_string()
5 new tests in gh_cmd.rs
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This pull request adds GitHub PR management commands (create, merge, diff, comment, edit), GitHub API JSON filtering, Git extension commands (branch, fetch, stash, worktree), and Cargo command wrappers (build, test, clippy) with compact output formatting.
Changes:
- Added 5 new
gh prsubcommands with confirmation messages and agh apicommand with JSON auto-detection - Added 4 new Git commands (branch, fetch, stash, worktree) with compact output filters
- Added Cargo build/test/clippy commands with compact error/warning display
- Extracted
filter_json_string()utility for reusable JSON schema extraction - Added
ok_confirmation()utility for consistent success message formatting - Added package manager detection utilities (unused but prepared for future use)
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils.rs | Added ok_confirmation() for write operation confirmations; added detect_package_manager() and package_manager_exec() utilities (unused); added tests |
| src/main.rs | Added Cargo command enum and routing; added Git branch/fetch/stash/worktree command routing |
| src/json_cmd.rs | Extracted filter_json_string() for reusable JSON parsing; refactored imports |
| src/git.rs | Made compact_diff() public for reuse; added branch/fetch/stash/worktree commands with compact output filters; added filter functions and tests |
| src/gh_cmd.rs | Added pr_create, pr_merge, pr_diff, pr_comment, pr_edit handlers; added run_api with JSON auto-detection; added tests for ok_confirmation |
| src/cargo_cmd.rs | New file with build/test/clippy commands and compact output filters; added comprehensive tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| &filtered, | ||
| ); | ||
|
|
||
| std::process::exit(output.status.code().unwrap_or(1)); |
There was a problem hiding this comment.
This function always exits with the status code, even when tests pass. This is inconsistent with run_build and run_clippy, which only exit on failure. This means successful test runs will cause the entire rtk process to exit, preventing any subsequent commands or cleanup from running. Consider adding a conditional check like in the other functions: if !output.status.success() { std::process::exit(output.status.code().unwrap_or(1)); }
| std::process::exit(output.status.code().unwrap_or(1)); | |
| if !output.status.success() { | |
| std::process::exit(output.status.code().unwrap_or(1)); | |
| } | |
| Ok(()) |
| "create" => pr_create(&args[1..], verbose), | ||
| "merge" => pr_merge(&args[1..], verbose), | ||
| "diff" => pr_diff(&args[1..], verbose), | ||
| "comment" => pr_action("commented", &args[1..], verbose), |
There was a problem hiding this comment.
The action passed to pr_action is "commented" but the function uses it to build the gh pr command at line 729. This means it will execute gh pr commented instead of gh pr comment, which will fail. The action parameter should be "comment" here, not "commented". The past tense should only be used in the confirmation message.
| "comment" => pr_action("commented", &args[1..], verbose), | |
| "comment" => pr_action("comment", &args[1..], verbose), |
| "comment" => pr_action("commented", &args[1..], verbose), | ||
| "edit" => pr_action("edited", &args[1..], verbose), |
There was a problem hiding this comment.
The action passed to pr_action is "edited" but the function uses it to build the gh pr command at line 729. This means it will execute gh pr edited instead of gh pr edit, which will fail. The action parameter should be "edit" here, not "edited". The past tense should only be used in the confirmation message.
| "comment" => pr_action("commented", &args[1..], verbose), | |
| "edit" => pr_action("edited", &args[1..], verbose), | |
| "comment" => pr_action("comment", &args[1..], verbose), | |
| "edit" => pr_action("edit", &args[1..], verbose), |
Summary
rtk gh pr create: capture URL + number, output "ok created #N url"rtk gh pr merge: "ok merged #N" confirmationrtk gh pr diff: reuse compact_diff() for condensed outputrtk gh pr comment: "ok commented #N"rtk gh pr edit: "ok edited #N"rtk gh api: auto-detect JSON, pipe through filter_json_string()Files changed
src/gh_cmd.rs— 5 new subcommand handlers in run_pr() + run_api()Test plan
cargo buildcompiles cleanDependencies
Depends on #30 (git extensions). Stacked PR series: PR 4/6
🤖 Generated with Claude Code