Skip to content
Snippets Groups Projects
Commit 3ed9d36a authored by Rhys Arkins's avatar Rhys Arkins
Browse files

refactor(gitfs): throw error if branch no longer exists

parent fa1eee1b
No related branches found
No related tags found
No related merge requests found
...@@ -227,8 +227,8 @@ class Storage { ...@@ -227,8 +227,8 @@ class Storage {
if (branchName) { if (branchName) {
const exists = await branchExists(branchName); const exists = await branchExists(branchName);
if (!exists) { if (!exists) {
logger.warn({ branchName }, 'getFile branch does not exist'); logger.info({ branchName }, 'branch no longer exists - aborting');
return null; throw new Error('repository-changed');
} }
} }
try { try {
......
...@@ -7,6 +7,8 @@ Array [ ...@@ -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`] = ` exports[`platform/git/storage getFileList() should return the correct files 1`] = `
Array [ Array [
"future_file", "future_file",
......
...@@ -167,8 +167,13 @@ describe('platform/git/storage', () => { ...@@ -167,8 +167,13 @@ describe('platform/git/storage', () => {
expect(res).toBe(null); expect(res).toBe(null);
}); });
it('returns null for 404', async () => { it('returns null for 404', async () => {
const res = await git.getFile('some-path', 'some-branch'); let e;
expect(res).toBe(null); try {
await git.getFile('some-path', 'some-branch');
} catch (err) {
e = err;
}
expect(e).toMatchSnapshot();
}); });
}); });
describe('commitFilesToBranch(branchName, files, message, parentBranch)', () => { describe('commitFilesToBranch(branchName, files, message, parentBranch)', () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment