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:
@@ -3674,7 +3674,7 @@ describe('updatePRState', () => {
|
||||
|
||||
expect(ghExecFileAsyncMock).toHaveBeenCalledWith(
|
||||
['pr', 'reopen', '3977', '--repo', 'stablyai/orca'],
|
||||
{ cwd: '/repo-root' }
|
||||
{ cwd: '/repo-root', host: 'github.com' }
|
||||
)
|
||||
expect(acquireMock).toHaveBeenCalledTimes(1)
|
||||
expect(releaseMock).toHaveBeenCalledTimes(1)
|
||||
@@ -3690,7 +3690,7 @@ describe('updatePRState', () => {
|
||||
|
||||
expect(ghExecFileAsyncMock).toHaveBeenCalledWith(
|
||||
['pr', 'close', '3977', '--repo', 'stablyai/orca'],
|
||||
{ cwd: '/repo-root' }
|
||||
{ cwd: '/repo-root', host: 'github.com' }
|
||||
)
|
||||
})
|
||||
|
||||
@@ -3706,7 +3706,7 @@ describe('updatePRState', () => {
|
||||
|
||||
expect(ghExecFileAsyncMock).toHaveBeenCalledWith(
|
||||
['pr', 'reopen', '3977', '--repo', 'stablyai/orca'],
|
||||
{}
|
||||
{ host: 'github.com' }
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -3795,12 +3795,12 @@ describe('GitHub GraphQL rate-limit guard', () => {
|
||||
expect(ghExecFileAsyncMock).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
['api', '--cache', '60s', 'repos/stablyai/orca/issues/7/comments?per_page=100'],
|
||||
{ cwd: '/repo-root' }
|
||||
{ cwd: '/repo-root', host: 'github.com' }
|
||||
)
|
||||
expect(ghExecFileAsyncMock).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
['api', '--cache', '60s', 'repos/stablyai/orca/pulls/7/reviews?per_page=100'],
|
||||
{ cwd: '/repo-root' }
|
||||
{ cwd: '/repo-root', host: 'github.com' }
|
||||
)
|
||||
})
|
||||
|
||||
@@ -3850,20 +3850,21 @@ describe('GitHub GraphQL rate-limit guard', () => {
|
||||
'--json',
|
||||
'number,title,state,url,statusCheckRollup,updatedAt,isDraft,mergeable,reviewDecision,mergeStateStatus,autoMergeRequest,baseRefName,headRefName,baseRefOid,headRefOid'
|
||||
],
|
||||
{ cwd: '/repo-root' }
|
||||
{ cwd: '/repo-root', host: 'github.com' }
|
||||
)
|
||||
expect(ghExecFileAsyncMock).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
['pr', 'merge', '7', '--squash', '--repo', 'stablyai/orca'],
|
||||
expect.objectContaining({
|
||||
cwd: '/repo-root',
|
||||
env: expect.objectContaining({ GH_PROMPT_DISABLED: '1' })
|
||||
env: expect.objectContaining({ GH_PROMPT_DISABLED: '1' }),
|
||||
host: 'github.com'
|
||||
})
|
||||
)
|
||||
expect(ghExecFileAsyncMock).toHaveBeenNthCalledWith(
|
||||
3,
|
||||
['pr', 'edit', '7', '--title', 'New title', '--repo', 'stablyai/orca'],
|
||||
{ cwd: '/repo-root' }
|
||||
{ cwd: '/repo-root', host: 'github.com' }
|
||||
)
|
||||
})
|
||||
|
||||
@@ -3892,7 +3893,7 @@ describe('GitHub GraphQL rate-limit guard', () => {
|
||||
expect(ghExecFileAsyncMock).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
['pr', 'view', '7', '--json', 'id,headRefOid,baseRefName', '--repo', 'stablyai/orca'],
|
||||
{}
|
||||
{ host: 'github.com' }
|
||||
)
|
||||
expect(ghExecFileAsyncMock).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
@@ -3907,14 +3908,16 @@ describe('GitHub GraphQL rate-limit guard', () => {
|
||||
'expectedHeadOid=head-oid'
|
||||
]),
|
||||
expect.objectContaining({
|
||||
env: expect.objectContaining({ GH_PROMPT_DISABLED: '1' })
|
||||
env: expect.objectContaining({ GH_PROMPT_DISABLED: '1' }),
|
||||
host: 'github.com'
|
||||
})
|
||||
)
|
||||
expect(ghExecFileAsyncMock).toHaveBeenNthCalledWith(
|
||||
3,
|
||||
['pr', 'merge', '7', '--disable-auto', '--repo', 'stablyai/orca'],
|
||||
expect.objectContaining({
|
||||
env: expect.objectContaining({ GH_PROMPT_DISABLED: '1' })
|
||||
env: expect.objectContaining({ GH_PROMPT_DISABLED: '1' }),
|
||||
host: 'github.com'
|
||||
})
|
||||
)
|
||||
expect(ghExecFileAsyncMock.mock.calls[0]?.[1]).not.toHaveProperty('cwd')
|
||||
|
||||
Reference in New Issue
Block a user