mirror of
https://github.com/stablyai/orca.git
synced 2026-11-18 20:06:10 +00:00
Patch PR titles without discovery reads (#35525)
Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
This commit is contained in:
@@ -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<void> {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user