diff --git a/lib/platform/github/index.js b/lib/platform/github/index.js index 0652b1d7432ffa1704784227124159aa4c84a160..3484477939dbb7c85f5a7a8314c8e5a112081f2c 100644 --- a/lib/platform/github/index.js +++ b/lib/platform/github/index.js @@ -89,6 +89,7 @@ async function initRepo(repoName, token, endpoint, forkMode, forkToken) { logger.trace({ repositoryDetails: res.body }, 'Repository details'); platformConfig.privateRepo = res.body.private === true; platformConfig.isFork = res.body.fork === true; + platformConfig.isArchived = res.body.archived === true; config.owner = res.body.owner.login; logger.debug(`${repoName} owner = ${config.owner}`); // Use default branch as PR target unless later overridden @@ -108,6 +109,9 @@ async function initRepo(repoName, token, endpoint, forkMode, forkToken) { logger.info({ err, res }, 'Unknown GitHub initRepo error'); throw err; } + if (platformConfig.isArchived) { + throw new Error('archived'); + } delete config.issueList; delete config.prList; delete config.fileList; diff --git a/lib/workers/repository/error.js b/lib/workers/repository/error.js index 8a6a04d2f0c746e133700e2da26e78ae993d334d..a4024ebd70badb1b2c303f1f918ad95db3a90920 100644 --- a/lib/workers/repository/error.js +++ b/lib/workers/repository/error.js @@ -12,6 +12,9 @@ async function handleError(config, err) { } else if (err.message === 'disabled') { logger.info('Repository is disabled - skipping'); return err.message; + } else if (err.message === 'archived') { + logger.info('Repository is archived - skipping'); + return err.message; } else if (err.message === 'fork') { logger.info('Repository is a fork and not manually configured - skipping'); return err.message; diff --git a/test/platform/github/__snapshots__/index.spec.js.snap b/test/platform/github/__snapshots__/index.spec.js.snap index 1be12fb0c2f5fd4b1ce9695fe8a73b1f0e168fd5..86f136e553905deaa6f04c241ecd57324d6a07c4 100644 --- a/test/platform/github/__snapshots__/index.spec.js.snap +++ b/test/platform/github/__snapshots__/index.spec.js.snap @@ -547,6 +547,7 @@ Array [ exports[`platform/github initRepo should forks when forkMode 1`] = ` Object { + "isArchived": false, "isFork": false, "privateRepo": false, } @@ -571,6 +572,7 @@ Array [ exports[`platform/github initRepo should initialise the config for the repo - 0 2`] = ` Object { + "isArchived": false, "isFork": false, "privateRepo": false, } @@ -595,6 +597,7 @@ Array [ exports[`platform/github initRepo should initialise the config for the repo - 1 2`] = ` Object { + "isArchived": false, "isFork": false, "privateRepo": false, } @@ -619,6 +622,7 @@ Array [ exports[`platform/github initRepo should initialise the config for the repo - 2 2`] = ` Object { + "isArchived": false, "isFork": false, "privateRepo": false, } @@ -626,6 +630,7 @@ Object { exports[`platform/github initRepo should merge 1`] = ` Object { + "isArchived": false, "isFork": false, "privateRepo": false, } @@ -633,6 +638,7 @@ Object { exports[`platform/github initRepo should not guess at merge 1`] = ` Object { + "isArchived": false, "isFork": false, "privateRepo": false, } @@ -640,6 +646,7 @@ Object { exports[`platform/github initRepo should rebase 1`] = ` Object { + "isArchived": false, "isFork": false, "privateRepo": false, } @@ -647,6 +654,7 @@ Object { exports[`platform/github initRepo should squash 1`] = ` Object { + "isArchived": false, "isFork": false, "privateRepo": false, } @@ -654,6 +662,7 @@ Object { exports[`platform/github initRepo should update fork when forkMode 1`] = ` Object { + "isArchived": false, "isFork": false, "privateRepo": false, } diff --git a/test/platform/github/index.spec.js b/test/platform/github/index.spec.js index f9fb1a97a0570e984fd99a571ee5b73cce616060..76bec2dfc5132df14dd3c6cb7fc3ed28fc36c589 100644 --- a/test/platform/github/index.spec.js +++ b/test/platform/github/index.spec.js @@ -324,6 +324,21 @@ describe('platform/github', () => { const config = await mergeInitRepo('some/repo', 'token'); expect(config).toMatchSnapshot(); }); + it('should throw error if archived', async () => { + get.mockReturnValueOnce({ + body: { + archived: true, + owner: {}, + }, + }); + let e; + try { + await github.initRepo('some/repo', 'token'); + } catch (err) { + e = err; + } + expect(e).toBeDefined(); + }); }); describe('getRepoForceRebase', () => { it('should detect repoForceRebase', async () => { diff --git a/test/workers/repository/error.spec.js b/test/workers/repository/error.spec.js index 7ded2443f277ad4c7649b327eb85ce0ca24a0a34..916a72e69c5d51d37c78f246be2b474696a47128 100644 --- a/test/workers/repository/error.spec.js +++ b/test/workers/repository/error.spec.js @@ -17,6 +17,7 @@ describe('workers/repository/error', () => { 'no-package-files', 'loops>5', 'config-validation', + 'archived', ]; errors.forEach(err => { it(`errors ${err}`, async () => {