Fix gh CLI GHES host pinning and rate-limit scope leaks

- Pin `--host` on every gh call site so a process-level GH_HOST can't
  silently redirect requests, and qualify `-R`/`-R=` repo shorthand
  alongside the existing `--repo=` handling.
- Check the target scope for an active rate-limit block before each
  WSL/native or host fallback retry, not just on the initial attempt,
  so a blocked scope can't be hit again through a fallback path.
- Compute idempotency once per call instead of re-deriving it after
  fallback reassigns args.
This commit is contained in:
Jinjing
2026-07-19 18:03:48 -07:00
parent 58034d2f74
commit 8ad7686fe3
10 changed files with 220 additions and 45 deletions
@@ -0,0 +1,19 @@
import { describe, expect, it } from 'vitest'
import { githubHostExecOptions } from './github-api-repository'
describe('githubHostExecOptions', () => {
it('pins every known repository host', () => {
expect(githubHostExecOptions({ owner: 'acme', repo: 'widgets', host: 'github.com' })).toEqual({
host: 'github.com'
})
expect(
githubHostExecOptions({ owner: 'acme', repo: 'widgets', host: 'github.acme-corp.com' })
).toEqual({ host: 'github.acme-corp.com' })
})
it('does not invent a host when repository identity is unavailable or legacy', () => {
expect(githubHostExecOptions({ owner: 'acme', repo: 'widgets' })).toEqual({})
expect(githubHostExecOptions(null)).toEqual({})
})
})