Skip to content

fix: check gh authentication for the target host only - #170

Merged
2 commits merged into
mainfrom
fix/gh-auth-status-hostname
Sep 27, 2026
Merged

2 commits merged into
mainfrom
fix/gh-auth-status-hostname

Conversation

@vitali87

Copy link
Copy Markdown
Owner

Summary

check_gh_auth ran a bare gh auth status, which exits 0 if any configured host is authenticated and 1 if any is broken. Two real failure modes:

  • an enterprise-only checkout (origin on ghe.example.com, authenticated there, nothing for github.com) was told to run gh auth login even though every gh call pr-split makes would succeed
  • a stale token for an unrelated host blocked splitting a github.com repo

The check now targets the host pr-split actually talks to: gh auth status --hostname <host>, where the host is $GH_HOST if set, else parsed from the origin remote URL (https/ssh/git/git+ssh and scp-like user@host:path, ports and userinfo stripped, lowercased to match gh's case-sensitive --hostname), else github.com. Single-label GHE hosts (git@ghe:org/repo) resolve correctly; local-path and file:// remotes fall back to github.com.

Test plan

  • 16 new tests: parametrised host derivation (22 URL shapes incl. upper-case hosts, ports, userinfo, single-label hosts, local paths), GH_HOST override short-circuiting git, --hostname passed to gh, unauthenticated → False; 15 of 16 fail on main
  • Review probed real gh auth status --hostname case-sensitivity and GHE-only hosts.yml configs across four passes
  • 460 tests pass, ruff clean
  • Local review: 5/5

@coderabbitai

coderabbitai Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 5bed05ab-10df-4fbc-b0f2-4f9a93d777dc

📥 Commits

Reviewing files that changed from the base of the PR and between 671a081 and 674ceb5.

📒 Files selected for processing (2)
  • pr_split/git_ops/prs.py
  • tests/test_git_prs.py

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015rnEEjXWDBdePRhKMmZr1w
@vitali87 vitali87 closed this pull request by merging all changes into main in 8ca9e3b Sep 27, 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.

2 participants