mirror of
https://github.com/aljazceru/gitpear.git
synced 2025-12-18 06:34:28 +01:00
git push upon share; helper for git child process
Signed-off-by: dzdidi <deniszalessky@gmail.com>
This commit is contained in:
@@ -44,8 +44,8 @@ program
|
|||||||
|
|
||||||
if (options.share) {
|
if (options.share) {
|
||||||
home.shareAppFolder(name)
|
home.shareAppFolder(name)
|
||||||
|
await git.push()
|
||||||
console.log(`Shared "${name}" project`)
|
console.log(`Shared "${name}" project`)
|
||||||
// push?
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -57,6 +57,7 @@ program
|
|||||||
const name = path.resolve(p).split(path.sep).pop()
|
const name = path.resolve(p).split(path.sep).pop()
|
||||||
if ((home.isInitialized(name))) {
|
if ((home.isInitialized(name))) {
|
||||||
home.shareAppFolder(name)
|
home.shareAppFolder(name)
|
||||||
|
await git.push()
|
||||||
console.log(`Shared "${name}" project`)
|
console.log(`Shared "${name}" project`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
26
src/git.js
26
src/git.js
@@ -23,23 +23,25 @@ async function lsPromise (url) {
|
|||||||
|
|
||||||
async function createBareRepo (name) {
|
async function createBareRepo (name) {
|
||||||
const init = spawn('git', ['init', '--bare'], { env: { GIT_DIR: getCodePath(name) } })
|
const init = spawn('git', ['init', '--bare'], { env: { GIT_DIR: getCodePath(name) } })
|
||||||
init.stderr.pipe(process.stderr)
|
return await doGit(init)
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
init.on('close', (code) => {
|
|
||||||
if (code) return reject(new Error(`git init exited with code ${code}`))
|
|
||||||
|
|
||||||
resolve()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function addRemote (name) {
|
async function addRemote (name) {
|
||||||
const init = spawn('git', ['remote', 'add', 'pear', getCodePath(name)])
|
const init = spawn('git', ['remote', 'add', 'pear', getCodePath(name)])
|
||||||
init.stderr.pipe(process.stderr)
|
return await doGit(init)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function push (branch = 'master') {
|
||||||
|
const push = spawn('git', ['push', 'pear', branch])
|
||||||
|
return await doGit(push)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function doGit (child) {
|
||||||
|
child.stderr.pipe(process.stderr)
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
init.on('close', (code) => {
|
child.on('close', (code) => {
|
||||||
if (code) {
|
if (code) {
|
||||||
return reject(new Error(`git remote add exited with code ${code}`))
|
return reject(new Error(`git exited with code ${code}`))
|
||||||
}
|
}
|
||||||
|
|
||||||
return resolve()
|
return resolve()
|
||||||
@@ -178,4 +180,4 @@ async function unpackStream (packStream) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { lsPromise, uploadPack, unpackFile, unpackStream, createBareRepo, addRemote }
|
module.exports = { lsPromise, uploadPack, unpackFile, unpackStream, createBareRepo, addRemote, push }
|
||||||
|
|||||||
Reference in New Issue
Block a user