Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip updating if upstream repo cannot be found #79

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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