diff --git a/lib/platform/github/__snapshots__/index.spec.ts.snap b/lib/platform/github/__snapshots__/index.spec.ts.snap index 16e5a208f8caf0..6ad946476d21ea 100644 --- a/lib/platform/github/__snapshots__/index.spec.ts.snap +++ b/lib/platform/github/__snapshots__/index.spec.ts.snap @@ -111,8 +111,14 @@ Array [ exports[`platform/github createPr() should create a draftPR if set in the settings 1`] = ` Object { "displayNumber": "Pull Request #123", + "head": Object { + "repo": Object { + "full_name": "some/repo", + }, + }, "number": 123, "sourceBranch": "some-branch", + "sourceRepo": "some/repo", } `; @@ -173,8 +179,14 @@ Array [ exports[`platform/github createPr() should create and return a PR object 1`] = ` Object { "displayNumber": "Pull Request #123", + "head": Object { + "repo": Object { + "full_name": "some/repo", + }, + }, "number": 123, "sourceBranch": "some-branch", + "sourceRepo": "some/repo", } `; @@ -249,8 +261,14 @@ Array [ exports[`platform/github createPr() should use defaultBranch 1`] = ` Object { "displayNumber": "Pull Request #123", + "head": Object { + "repo": Object { + "full_name": "some/repo", + }, + }, "number": 123, "sourceBranch": "some-branch", + "sourceRepo": "some/repo", } `; diff --git a/lib/platform/github/index.spec.ts b/lib/platform/github/index.spec.ts index c23fade4c45164..14193e6c1457a5 100644 --- a/lib/platform/github/index.spec.ts +++ b/lib/platform/github/index.spec.ts @@ -1598,6 +1598,7 @@ describe('platform/github', () => { .post('/repos/some/repo/pulls') .reply(200, { number: 123, + head: { repo: { full_name: 'some/repo' } }, }) .post('/repos/some/repo/issues/123/labels') .reply(200, []); @@ -1617,6 +1618,7 @@ describe('platform/github', () => { initRepoMock(scope, 'some/repo'); scope.post('/repos/some/repo/pulls').reply(200, { number: 123, + head: { repo: { full_name: 'some/repo' } }, }); await github.initRepo({ repository: 'some/repo', token: 'token' } as any); const pr = await github.createPr({ @@ -1634,6 +1636,7 @@ describe('platform/github', () => { initRepoMock(scope, 'some/repo'); scope.post('/repos/some/repo/pulls').reply(200, { number: 123, + head: { repo: { full_name: 'some/repo' } }, }); await github.initRepo({ repository: 'some/repo', token: 'token' } as any); const pr = await github.createPr({ diff --git a/lib/platform/github/index.ts b/lib/platform/github/index.ts index 2eb257ea373caa..19ccdefdfced7f 100644 --- a/lib/platform/github/index.ts +++ b/lib/platform/github/index.ts @@ -49,8 +49,6 @@ import { Comment, GhBranchStatus, GhGraphQlPr, - GhPr, - GhPulls, GhRepo, GhRestPr, LocalRepoConfig, @@ -694,10 +692,10 @@ export async function getPrList(): Promise { logger.trace('getPrList()'); if (!config.prList) { logger.debug('Retrieving PR list'); - let prList: GhPulls; + let prList: GhRestPr[]; try { prList = ( - await githubApi.getJson( + await githubApi.getJson( `repos/${ config.parentRepo || config.repository }/pulls?per_page=100&state=all`, @@ -1389,7 +1387,7 @@ export async function createPr({ } logger.debug({ title, head, base, draft: draftPR }, 'Creating PR'); const pr = ( - await githubApi.postJson( + await githubApi.postJson( `repos/${config.parentRepo || config.repository}/pulls`, options ) @@ -1404,6 +1402,7 @@ export async function createPr({ } pr.displayNumber = `Pull Request #${pr.number}`; pr.sourceBranch = sourceBranch; + pr.sourceRepo = pr.head.repo.full_name; await addLabels(pr.number, labels); return pr; } diff --git a/lib/platform/github/types.ts b/lib/platform/github/types.ts index f48867c89f3f51..20dc963b401879 100644 --- a/lib/platform/github/types.ts +++ b/lib/platform/github/types.ts @@ -26,8 +26,19 @@ export interface GhPr extends Pr { } export interface GhRestPr extends GhPr { - head: { ref: string; sha: string }; + head: { + ref: string; + sha: string; + repo: { full_name: string }; + }; mergeable_state: string; + number: number; + title: string; + state: string; + merged_at: string; + created_at: string; + closed_at: string; + user?: { login?: string }; } export interface GhGraphQlPr extends GhPr { @@ -81,18 +92,3 @@ export interface GhRepo { }; }; } - -export type GhPulls = { - number: number; - head: { - ref: string; - sha: string; - repo: { full_name: string }; - }; - title: string; - state: string; - merged_at: string; - created_at: string; - closed_at: string; - user?: { login?: string }; -}[];