Browse Source

Try to clone git repositories over SSH on failure (#671)

* updated help message for `now switch` to reference the argument for the team as the slug instead of the id

* try ssh if https does not work

* add editor settings to .gitignore, update yarn.lock

* reverting change to teams in separate pr

* Removed unused ignored prop
master
David Corwin 8 years ago
committed by Leo Lamprecht
parent
commit
348b19e54d
  1. 13
      lib/git.js

13
lib/git.js

@ -9,7 +9,7 @@ const download = require('download')
const tmp = require('tmp-promise')
const isURL = require('is-url')
const cloneRepo = (parts, tmpDir) =>
const cloneRepo = (parts, tmpDir, { ssh }) =>
new Promise((resolve, reject) => {
let host
@ -24,7 +24,10 @@ const cloneRepo = (parts, tmpDir) =>
host = `github.com`
}
const url = `https://${host}/${parts.main}`
const url = ssh
? `git@${host}:${parts.main}`
: `https://${host}/${parts.main}`
const ref = parts.ref || (parts.type === 'Bitbucket' ? 'default' : 'master')
const cmd = `git clone ${url} --single-branch ${ref}`
@ -131,7 +134,11 @@ const downloadRepo = async repoPath => {
try {
await cloneRepo(pathParts, tmpDir)
} catch (err) {
gitInstalled = false
try {
await cloneRepo(pathParts, tmpDir, { ssh: true })
} catch (err) {
gitInstalled = false
}
}
if (gitInstalled) {

Loading…
Cancel
Save