Skip to content

feat(review): support GitHub Enterprise and fix self-hosted GitLab MR diffs - #460

Merged
backnotprop merged 2 commits into
mainfrom
feat/enterprise-vcs
Apr 1, 2026
Merged

backnotprop merged 2 commits into
mainfrom
feat/enterprise-vcs

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Summary

Closes #348
Closes #457

Test plan

  • All 28 existing tests pass (bun test packages/shared/)
  • 2 new tests added: GHE URL parsing, GHE/GitLab URL disambiguation
  • Manual: plannotator review https://ghe.example.com/owner/repo/pull/N parses and authenticates
  • Manual: plannotator review https://gitlab.selfhosted.com/group/project/-/merge_requests/N fetches diff without --hostname error

… diffs

Add `host` field to GitHub PR types and update URL parsing to accept any
host with `/pull/` pattern, enabling GitHub Enterprise Server URLs like
`ghe.company.com/owner/repo/pull/123`. All 8 `gh` CLI functions now pass
`--hostname` (for `gh api`/`gh auth`) and `HOST/OWNER/REPO` (for `gh pr`)
when targeting non-github.com hosts.

Replace broken `glab mr diff --hostname` invocation (glab mr subcommands
don't support --hostname) with `glab api .../diffs` which does. Diffs are
now reconstructed from structured API response instead of heuristic parsing
of bare diff output.

Closes #348
Closes #457

For provenance purposes, this commit was AI assisted.
@backnotprop

Copy link
Copy Markdown
Owner Author

Code review

Found 1 issue:

  1. parsePaginatedArray regex \]\s*\[ can corrupt JSON when diff content contains ][ (e.g., multi-dimensional array indexing like arr[0][1]). The regex operates on raw text without respecting JSON string boundaries, so ][ inside a "diff" string value would be replaced with ,, silently corrupting the parsed data. Consider splitting on top-level array boundaries using a JSON-aware approach instead of naive text replacement.

/** Parse potentially concatenated JSON arrays from glab api --paginate output */
function parsePaginatedArray<T>(stdout: string): T[] {
// glab --paginate concatenates pages: [...][...] → merge into one array
const fixed = stdout.replace(/\]\s*\[/g, ",");
return JSON.parse(fixed) as T[];
}

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

glab api --paginate already returns a single merged JSON array, so the
regex that replaced ][  with , was unnecessary and could corrupt diff
content containing array indexing patterns like arr[i][j].

For provenance purposes, this commit was AI assisted.
@backnotprop
backnotprop merged commit 588b6a4 into main Apr 1, 2026
5 checks passed
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.

glab mr subcommands fail with --hostname on self-hosted GitLab Code Review Enhancements & GitHub PR Integration

1 participant