git ssb

39+

cel / git-ssb



Tree: c51a7c32602d5b5501312e9ad0344b4a93fdd8f8

Files: c51a7c32602d5b5501312e9ad0344b4a93fdd8f8 / lib / create.js

941 bytesRaw
1var u = require('./util')
2
3function hasRemote(name) {
4 var child = proc.spawnSync('git', ['remote'], {encoding: 'utf8'})
5 var remotes = child.stdout.split(/\n/)
6 return !!~remotes.indexOf(name)
7}
8
9module.exports = function (config, remoteName, name, upstream) {
10 if (config._.length == 0) return require('./help')('create')
11 if (!remoteName) throw 'Missing remote name'
12 if (hasRemote(remoteName))
13 throw 'Remote \'' + remoteName + '\' already exists'
14 u.getSbot(config, function (err, sbot) {
15 if (err) throw err
16 require('ssb-git-repo').createRepo(sbot, {
17 upstream: upstream,
18 name: name
19 }, function (err, repo) {
20 if (err) throw err
21 var url = 'ssb://' + repo.id
22 console.log('Created repo:', url, name ? '(' + name + ')' : '')
23 proc.spawnSync('git', ['remote', 'add', remoteName, url])
24 console.log('Added remote:', remoteName)
25 repo.close()
26 sbot.close()
27 })
28 })
29}
30
31

Built with git-ssb-web