155
156
async findPullRequestByHeadBranch(owner: string, repo: string, branch: string, token: string, signal: AbortSignal): Promise<CreatedPullRequest | undefined> {
157
>
const routeSlug = `repos/${owner}/${repo}/pulls?head=${encodeURIComponent(`${owner}:${branch}`)}&state=all&sort=updated&direction=desc&per_page=1`;
agentHostOctoKitService.ts
158
>
159
>
const etag = this.pullRequestSearchEtags.get(routeSlug);
160
>
const response = await this._makeGHAPIRequest<GitHubPullRequestResponseItem[]>(routeSlug, 'GET', token, signal, undefined, etag);
161
>
162
>
if (response.etag) {
163
this.pullRequestSearchEtags.set(routeSlug, response.etag);
164
}
166
>
if (
167
>
response.statusCode === 304 ||
168
>
!Array.isArray(response.data) ||
169
>
response.data.length === 0
170
>
) {
171
return undefined;
172
}
174
>
const first = response.data[0];
175
>
const html_url = first?.html_url;
176
>
const number = first?.number;
177
>
const node_id = first?.node_id;
178
>
return typeof html_url === 'string' && typeof number === 'number'
179
>
? {
180
>
number,
181
>
url: html_url,
182
>
nodeId: typeof node_id === 'string'
183
>
? node_id
184
: undefined
186
: undefined;
188
189
async enablePullRequestAutoMerge(pullRequestId: string, mergeMethod: AutoMergeMethod, token: string, signal: AbortSignal): Promise<void> {