1
0
mirror of synced 2026-03-23 14:02:01 +00:00

build(integration): clone properly from the local repo when in a detached HEAD state

This commit is contained in:
Jason Dreyzehner
2018-03-20 20:51:55 -04:00
parent 1e14d03596
commit 369a3b46b6
3 changed files with 17 additions and 10 deletions

View File

@@ -40,7 +40,8 @@ const branch = execa.sync('git', [
'HEAD'
]).stdout;
const repoInfo = {
branch: branch === 'HEAD' ? 'master' : branch,
// if local repo is in a detached HEAD state, providing --branch to `git clone` will fail.
branch: branch === 'HEAD' ? '.' : branch,
repo: process.cwd()
};
const buildDir = join(process.cwd(), 'build');

View File

@@ -138,7 +138,7 @@ const mockErr = (code?: string | number) =>
test('cloneRepo: errors when Git is not installed on PATH', async t => {
const error = await t.throws(
cloneRepo(mockErr('ENOENT'))({ repo: 'r', branch: 'b' }, 'd', 'p')
cloneRepo(mockErr('ENOENT'))({ repo: 'r', branch: '.' }, 'd', 'p')
);
t.regex(error.message, /Git is not installed on your PATH/);
});