diff --git a/lib/platform/git/storage.js b/lib/platform/git/storage.js index 09b446cd275edfe44f2836dd1caccc3db51b34f1..137b5fddd27668008b849c28d7e4bb9a98cd1d4e 100644 --- a/lib/platform/git/storage.js +++ b/lib/platform/git/storage.js @@ -227,8 +227,8 @@ class Storage { if (branchName) { const exists = await branchExists(branchName); if (!exists) { - logger.warn({ branchName }, 'getFile branch does not exist'); - return null; + logger.info({ branchName }, 'branch no longer exists - aborting'); + throw new Error('repository-changed'); } } try { diff --git a/test/platform/git/__snapshots__/storage.spec.js.snap b/test/platform/git/__snapshots__/storage.spec.js.snap index fed1144398d8d738f350044e04468f08819c135d..3c62c1e7bbf8de5d58da8f172a617cb047109500 100644 --- a/test/platform/git/__snapshots__/storage.spec.js.snap +++ b/test/platform/git/__snapshots__/storage.spec.js.snap @@ -7,6 +7,8 @@ Array [ ] `; +exports[`platform/git/storage getFile(filePath, branchName) returns null for 404 1`] = `[Error: repository-changed]`; + exports[`platform/git/storage getFileList() should return the correct files 1`] = ` Array [ "future_file", diff --git a/test/platform/git/storage.spec.js b/test/platform/git/storage.spec.js index fcca6638d9d77e5ad95f7f7a6888e5ea0f5ac663..1cdbc061c35430b6a470621727202dd3bb24514c 100644 --- a/test/platform/git/storage.spec.js +++ b/test/platform/git/storage.spec.js @@ -167,8 +167,13 @@ describe('platform/git/storage', () => { expect(res).toBe(null); }); it('returns null for 404', async () => { - const res = await git.getFile('some-path', 'some-branch'); - expect(res).toBe(null); + let e; + try { + await git.getFile('some-path', 'some-branch'); + } catch (err) { + e = err; + } + expect(e).toMatchSnapshot(); }); }); describe('commitFilesToBranch(branchName, files, message, parentBranch)', () => {