Skip to content

Commit

Permalink
skip updating if upstream repo cannot be found (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanessayuenn authored Dec 11, 2020
1 parent 5ecbad3 commit 13bf4ab
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/autoupdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ export class AutoUpdater {
);
return false;
}
if (!pull.head.repo) {
ghCore.warning(
`Skipping pull request, fork appears to have been deleted.`,
);
return false;
}

const { data: comparison } = await this.octokit.repos.compareCommits({
owner: pull.head.repo.owner.login,
Expand Down
13 changes: 13 additions & 0 deletions test/autoupdate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ describe('test `prNeedsUpdate`', () => {
expect(needsUpdate).toEqual(false);
});

test('originating repo of pull request has been deleted', async () => {
const pull = Object.assign({}, validPull, {
head: {
label: head,
ref: head,
repo: null,
},
});
const updater = new AutoUpdater(config, {});
const needsUpdate = await updater.prNeedsUpdate(pull);
expect(needsUpdate).toEqual(false);
});

test('pull request is not behind', async () => {
const scope = nock('https://api.github.com:443')
.get(`/repos/${owner}/${repo}/compare/${head}...${base}`)
Expand Down

0 comments on commit 13bf4ab

Please sign in to comment.