Skip to content

Conversation

@LSRCT
Copy link
Contributor

@LSRCT LSRCT commented Jan 5, 2026

Summary

  • Remove hardcoded github.com URL parsing in the review CLI crate
  • Delegate URL parsing to the gh CLI which handles GitHub Enterprise hostnames automatically
  • Fix JSON response parsing to use separate headRepository and headRepositoryOwner fields

What changed

crates/review/src/github.rs

  • Removed parse_pr_url() function that had hardcoded github.com check
  • Updated get_pr_info() to accept raw PR URL and pass it directly to gh pr view
  • Added GhRepoOwner and GhRepo structs to parse the gh CLI JSON response correctly
  • Extract owner/repo from headRepositoryOwner.login and headRepository.name fields

crates/review/src/main.rs

  • Simplified flow: now calls get_pr_info(&args.pr_url) directly instead of parsing URL first
  • Uses pr_info.owner and pr_info.repo from the gh response

crates/review/src/error.rs

  • Removed unused InvalidPrUrl error variant

Why

GitHub Enterprise instances use different hostnames (e.g., github.mycompany.com). The previous implementation rejected any URL that didn't contain github.com, breaking GHE support.

By delegating to the gh CLI, we get automatic support for:

  • GitHub Enterprise hostnames
  • SSH hostname aliases from ~/.ssh/config
  • Proper authentication handling per host

Testing

  • tested

This PR was written using Vibe Kanban

@vibe-kanban-cloud
Copy link

Review Complete

Your review story is ready!

View Story

Comment !reviewfast on this PR to re-generate the story.

@LSRCT LSRCT changed the title GH url parsing for review crate (vibe-kanban) Fix GitHub Enterprise URL parsing in review crate (Vibe Kanban) Jan 5, 2026
@LSRCT LSRCT requested a review from stunningpixels January 5, 2026 19:00
@LSRCT LSRCT force-pushed the vk/e220-support-hosted-g branch from ee8ebd3 to f1e4e7b Compare January 6, 2026 10:28
Base automatically changed from vk/e220-support-hosted-g to main January 6, 2026 10:43
@LSRCT LSRCT force-pushed the vk/4afe-gh-url-parsing-f branch from 13f6c77 to 328b9ae Compare January 6, 2026 10:45
LSRCT added 4 commits January 6, 2026 10:45
## Summary

I've successfully fixed the GitHub Enterprise URL parsing issue in the `crates/review/` crate by delegating URL parsing to the `gh` CLI instead of manually parsing URLs.

### Changes Made

1. **`crates/review/src/github.rs`**:
   - Removed the `parse_pr_url()` function that had hardcoded `"github.com"` check
   - Added `GhRepoOwner` and `GhRepo` structs to parse repository info from `gh` response
   - Updated `GhPrView` struct to include `head_repository` field
   - Modified `get_pr_info()` to accept the raw PR URL and extract owner/repo from the `gh pr view` JSON response
   - Removed unit tests for `parse_pr_url()` (no longer needed)

2. **`crates/review/src/main.rs`**:
   - Removed import of `parse_pr_url`
   - Simplified the flow: now just calls `get_pr_info(&args.pr_url)` directly
   - Uses `pr_info.owner` and `pr_info.repo` from the response
   - Updated step numbers in comments

3. **`crates/review/src/error.rs`**:
   - Removed `InvalidPrUrl` error variant (no longer needed since `gh` handles URL validation)

### How It Works Now

Instead of:
```rust
let (owner, repo, pr_number) = parse_pr_url(&args.pr_url)?;  // Hardcoded github.com check
let pr_info = get_pr_info(&owner, &repo, pr_number)?;
```

The new flow is:
```rust
let pr_info = get_pr_info(&args.pr_url)?;  // gh CLI handles all URL parsing
// pr_info.owner and pr_info.repo are extracted from gh response
```

This approach:
- Eliminates hardcoded hostname checks
- Supports GitHub Enterprise instances automatically
- Supports SSH hostname aliases from `~/.ssh/config`
- Matches the pattern used in `crates/services/`
- Lets `gh` handle authentication for different GitHub hosts
1. Removed `/// Repository owner info from \`gh pr view --json\`` (line 20)
2. Removed `/// Repository info from \`gh pr view --json\`` (line 26)
3. Removed the multi-line doc comment for `get_pr_info`:
   - `/// Get PR information using \`gh pr view\` with the raw URL`
   - `///`
   - `/// This accepts any GitHub PR URL (including GitHub Enterprise) and lets \`gh\``
   - `/// handle the hostname resolution and authentication.`
…sitoryOwner` as separate fields, not nested. Try running it again:

```bash
cargo run -p review -- #1
```
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