diff --git a/lib/github.js b/lib/github.js index 7f97f69..a257a3c 100644 --- a/lib/github.js +++ b/lib/github.js @@ -7,7 +7,8 @@ import download from 'download' import tmp from 'tmp-promise' const downloadRepo = async repoPath => { - const url = `https://api.github.com/repos/${repoPath}/tarball` + const pathParts = gitPathParts(repoPath) + const url = `https://api.github.com/repos/${pathParts.main}/tarball/${pathParts.ref}` const tmpDir = await tmp.dir({ // We'll remove it manually once deployment is done @@ -31,6 +32,19 @@ const downloadRepo = async repoPath => { return tmpDir } +export const gitPathParts = main => { + let ref = '' + + if (main.split('/')[1].includes('#')) { + const parts = main.split('#') + + ref = parts[1] + main = parts[0] + } + + return {main, ref} +} + export const isRepoPath = path => { if (!path) { return false