Skip to content

feat: gh pr create/merge/diff/comment/edit + gh api#31

Merged
pszymkowiak merged 4 commits intortk-ai:masterfrom
FlorianBruniaux:feat/gh-expansion
Feb 1, 2026
Merged

feat: gh pr create/merge/diff/comment/edit + gh api#31
pszymkowiak merged 4 commits intortk-ai:masterfrom
FlorianBruniaux:feat/gh-expansion

Conversation

@FlorianBruniaux
Copy link
Collaborator

Summary

  • rtk gh pr create: capture URL + number, output "ok created #N url"
  • rtk gh pr merge: "ok merged #N" confirmation
  • rtk gh pr diff: reuse compact_diff() for condensed output
  • rtk 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

  • 5 tests (ok_confirmation for create/merge/comment/edit + truncate)
  • cargo build compiles clean
  • No main.rs changes needed (routing handled internally)

Dependencies

Depends on #30 (git extensions). Stacked PR series: PR 4/6

🤖 Generated with Claude Code

FlorianBruniaux and others added 4 commits January 31, 2026 23:34
- 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>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 pr subcommands with confirmation messages and a gh api command 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));
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)); }

Suggested change
std::process::exit(output.status.code().unwrap_or(1));
if !output.status.success() {
std::process::exit(output.status.code().unwrap_or(1));
}
Ok(())

Copilot uses AI. Check for mistakes.
"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),
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"comment" => pr_action("commented", &args[1..], verbose),
"comment" => pr_action("comment", &args[1..], verbose),

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +42
"comment" => pr_action("commented", &args[1..], verbose),
"edit" => pr_action("edited", &args[1..], verbose),
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"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),

Copilot uses AI. Check for mistakes.
@pszymkowiak pszymkowiak merged commit 2af9698 into rtk-ai:master Feb 1, 2026
6 of 7 checks passed
ahundt pushed a commit to ahundt/rtk that referenced this pull request Feb 23, 2026
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.

3 participants