Browse Source

Support for Bitbucket

master
Leo Lamprecht 8 years ago
parent
commit
9bfa06f163
No known key found for this signature in database GPG Key ID: B08517883D5E0E10
  1. 23
      lib/git.js

23
lib/git.js

@ -17,6 +17,9 @@ const downloadRepo = async repoPath => {
const ref = pathParts.ref ? `?ref=${pathParts.ref}` : '' const ref = pathParts.ref ? `?ref=${pathParts.ref}` : ''
url = `https://gitlab.com/${pathParts.main}/repository/archive.tar` + ref url = `https://gitlab.com/${pathParts.main}/repository/archive.tar` + ref
break break
case 'Bitbucket':
url = `https://bitbucket.org/${pathParts.main}/get/${pathParts.ref || 'master'}.zip`
break
default: default:
url = `https://api.github.com/repos/${pathParts.main}/tarball/${pathParts.ref}` url = `https://api.github.com/repos/${pathParts.main}/tarball/${pathParts.ref}`
} }
@ -44,7 +47,13 @@ const downloadRepo = async repoPath => {
} }
const capitalizePlatform = name => { const capitalizePlatform = name => {
return name.replace('github', 'GitHub').replace('gitlab', 'GitLab') const names = {
github: 'GitHub',
gitlab: 'GitLab',
bitbucket: 'Bitbucket'
}
return names[name]
} }
const splittedURL = fullURL => { const splittedURL = fullURL => {
@ -62,9 +71,12 @@ const splittedURL = fullURL => {
// Assign Git reference // Assign Git reference
let ref = pathParts.length >= 2 ? pathParts[1] : '' let ref = pathParts.length >= 2 ? pathParts[1] : ''
// Shorten SHA for commits // Firstly be sure that we haven know the ref type
if (pathParts[0] && pathParts[0] === 'commit') { if (pathParts[0]) {
ref = ref.substring(0, 7) // Then shorten the SHA of the commit
if (pathParts[0] === 'commit' || pathParts[0] === 'commits') {
ref = ref.substring(0, 7)
}
} }
// We're deploying master by default, // We're deploying master by default,
@ -108,7 +120,8 @@ export const isRepoPath = path => {
const allowedHosts = [ const allowedHosts = [
'github.com', 'github.com',
'gitlab.com' 'gitlab.com',
'bitbucket.org'
] ]
if (isURL(path)) { if (isURL(path)) {

Loading…
Cancel
Save