fix: modify fetch function to handle CircleCI specifics

This commit is contained in:
Pierre Vanduynslager
2019-12-03 18:07:12 -05:00
parent b2c1b2c670
commit cbef9d18da
6 changed files with 114 additions and 28 deletions
+11
View File
@@ -166,6 +166,17 @@ export async function gitDetachedHead(repositoryUrl, head) {
return cwd;
}
export async function gitDetachedHeadFromBranch(repositoryUrl, branch, head) {
const cwd = tempy.directory();
await execa('git', ['init'], {cwd});
await execa('git', ['remote', 'add', 'origin', repositoryUrl], {cwd});
await execa('git', ['fetch', '--force', repositoryUrl, `${branch}:remotes/origin/${branch}`], {cwd});
await execa('git', ['reset', '--hard', head], {cwd});
await execa('git', ['checkout', '-q', '-B', branch], {cwd});
return cwd;
}
/**
* Add a new Git configuration.
*