diff --git a/src/main/github/client-merge-queue-auto-merge.test.ts b/src/main/github/client-merge-queue-auto-merge.test.ts index edc0ec53a70..b1af6ee3f7d 100644 --- a/src/main/github/client-merge-queue-auto-merge.test.ts +++ b/src/main/github/client-merge-queue-auto-merge.test.ts @@ -91,7 +91,7 @@ describe('GitHub GraphQL rate-limit guard', () => { }) ).resolves.toEqual({ ok: true }) await expect( - updatePRTitle('/repo-root', 7, 'New title', undefined, { + updatePRTitle('/repo-root', 7, ' New title @literal ', undefined, { owner: 'stablyai', repo: 'orca', host: 'github.com' @@ -131,7 +131,14 @@ describe('GitHub GraphQL rate-limit guard', () => { ) expect(ghExecFileAsyncMock).toHaveBeenNthCalledWith( 4, - ['pr', 'edit', '7', '--title', 'New title', '--repo', 'stablyai/orca'], + [ + 'api', + '-X', + 'PATCH', + 'repos/stablyai/orca/pulls/7', + '--raw-field', + 'title= New title @literal ' + ], { cwd: '/repo-root', host: 'github.com' } ) }) diff --git a/src/main/github/client/update/pr-details.ts b/src/main/github/client/update/pr-details.ts index 2bc4c22a316..e57af86c02a 100644 --- a/src/main/github/client/update/pr-details.ts +++ b/src/main/github/client/update/pr-details.ts @@ -6,7 +6,30 @@ import { classifyPullRequestUpdateError, type LocalGitExecOptions } from '../../gh-utils' -import { resolveGitHubRepoExecution, type GitHubApiRepository } from '../../github-api-repository' +import { + resolveGitHubRepoExecution, + type GitHubApiRepository, + type GitHubRepoExecOptions +} from '../../github-api-repository' + +async function patchPullRequest( + repository: GitHubApiRepository, + prNumber: number, + fields: string[], + ghOptions: GitHubRepoExecOptions +): Promise { + await ghExecFileAsync( + [ + 'api', + '-X', + 'PATCH', + `repos/${repository.owner}/${repository.repo}/pulls/${prNumber}`, + ...fields.flatMap((field) => ['--raw-field', field]) + ], + ghOptions + ) +} + export async function updatePRTitle( repoPath: string, prNumber: number, @@ -26,13 +49,7 @@ export async function updatePRTitle( } await acquire() try { - const args = ['pr', 'edit', String(prNumber), '--title', title] - if (ownerRepo) { - args.push('--repo', `${ownerRepo.owner}/${ownerRepo.repo}`) - } - await ghExecFileAsync(args, { - ...ghOptions - }) + await patchPullRequest(ownerRepo, prNumber, [`title=${title}`], ghOptions) invalidateReviewLookupsAfterPRMutation(repoPath, connectionId) return true } catch (err) { @@ -78,16 +95,7 @@ export async function updatePRDetails( await acquire() try { - await ghExecFileAsync( - [ - 'api', - '-X', - 'PATCH', - `repos/${ownerRepo.owner}/${ownerRepo.repo}/pulls/${prNumber}`, - ...fields.flatMap((field) => ['--raw-field', field]) - ], - ghOptions - ) + await patchPullRequest(ownerRepo, prNumber, fields, ghOptions) invalidateReviewLookupsAfterPRMutation(repoPath, connectionId) return { ok: true } } catch (err) {