|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// PB : TODO -- Use queueing with async tasks.. |
|
|
// PB : TODO -- Use queueing with async tasks.. |
|
|
var performPull = (repodef, branch, repoowner, errHandler) => { |
|
|
|
|
|
|
|
|
var performPull = (repodef, branch, repoowner, errHandler, elevatedBatch, regularBatch) => { |
|
|
|
|
|
var __inelevatedBatch = elevatedBatch, __inregularBatch = regularBatch; |
|
|
|
|
|
var pT = getPullTask(repodef, branch, repoowner, errHandler, elevatedBatch, regularBatch) |
|
|
|
|
|
// var waitForBatchAdditions = function(){ |
|
|
|
|
|
// return pT; |
|
|
|
|
|
// } |
|
|
|
|
|
// Execute is implied. |
|
|
|
|
|
// if(false && (__inelevatedBatch || __inregularBatch) ) return waitForBatchAdditions() // PB : Todo Implemnt a trigger which starts execution. |
|
|
|
|
|
// else |
|
|
|
|
|
return pT() // Execute it. |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var getPullTask = (repodef, branch, repoowner, errHandler, elevatedBatch, regularBatch) => { |
|
|
// PB : TODO -- Handle no branch passed in case. |
|
|
// PB : TODO -- Handle no branch passed in case. |
|
|
// if(!branch) { throw 'No branch specified' } |
|
|
// if(!branch) { throw 'No branch specified' } |
|
|
var repo = repodef.repo; |
|
|
var repo = repodef.repo; |
|
|
|
|
|
elevatedBatch = elevatedBatch || []; |
|
|
|
|
|
regularBatch = regularBatch || []; |
|
|
try{ |
|
|
try{ |
|
|
var exists = existsSync(instanceroot + '/' + repo) |
|
|
var exists = existsSync(instanceroot + '/' + repo) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
console.log(e) |
|
|
console.log(e) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function initTask(etask){ |
|
|
|
|
|
etask.info = { repo } |
|
|
|
|
|
etask.errHandler = errHandler |
|
|
|
|
|
etask.statuslog = statuslog |
|
|
|
|
|
etask.processedArgs = processedArgs |
|
|
|
|
|
etask.selectedinstance = selectedinstance |
|
|
|
|
|
etask.runtimestamp = runtimestamp |
|
|
|
|
|
etask.ENV = ENV |
|
|
|
|
|
|
|
|
|
|
|
elevatedBatch.info = { repo } |
|
|
|
|
|
elevatedBatch.errHandler = errHandler |
|
|
|
|
|
elevatedBatch.statuslog = statuslog |
|
|
|
|
|
elevatedBatch.processedArgs = processedArgs |
|
|
|
|
|
elevatedBatch.selectedinstance = selectedinstance |
|
|
|
|
|
elevatedBatch.runtimestamp = runtimestamp |
|
|
|
|
|
elevatedBatch.ENV = ENV |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (exists) { |
|
|
if (exists) { |
|
|
var branchprint = branch ? ' branch :' + branch : ''; |
|
|
var branchprint = branch ? ' branch :' + branch : ''; |
|
|
console.log('pulling ' + instanceroot + '/' + repo + branchprint ) |
|
|
console.log('pulling ' + instanceroot + '/' + repo + branchprint ) |
|
|
|
|
|
|
|
|
return true; |
|
|
return true; |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
initTask(task) |
|
|
|
|
|
|
|
|
task.info = { repo } |
|
|
|
|
|
task.errHandler = errHandler |
|
|
|
|
|
task.statuslog = statuslog |
|
|
|
|
|
task.processedArgs = processedArgs |
|
|
|
|
|
task.selectedinstance = selectedinstance |
|
|
|
|
|
task.runtimestamp = runtimestamp |
|
|
|
|
|
task.ENV = ENV |
|
|
|
|
|
if(repodef.requiresElevation) return shell_verse.runElevated( task ) |
|
|
|
|
|
else return shell_verse.runTask( task ) |
|
|
|
|
|
|
|
|
if(repodef.requiresElevation) { |
|
|
|
|
|
elevatedBatch.push(shell_verse.getElevatedTask( task )); |
|
|
|
|
|
return elevatedBatch[elevatedBatch.length-1] |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
regularBatch.push(shell_verse.getNonElevatedTask( task )) |
|
|
|
|
|
return regularBatch[regularBatch.length-1] |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
console.log('cloning ' + repo) |
|
|
console.log('cloning ' + repo) |
|
|
// PB : TODO -- detect if a clonable repo exists in currentGitAuthUser |
|
|
// PB : TODO -- detect if a clonable repo exists in currentGitAuthUser |
|
|
|
|
|
|
|
|
var task = ()=>{ |
|
|
var task = ()=>{ |
|
|
return nodeShellExec('git', ['clone', '-c', 'core.symlinks=true', selectedinstance.reposerver + `/${repoowner || defaultRepoOwner}/` + repo + '.git'], |
|
|
return nodeShellExec('git', ['clone', '-c', 'core.symlinks=true', selectedinstance.reposerver + `/${repoowner || defaultRepoOwner}/` + repo + '.git'], |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
, title: `'git', ${['config', '--replace-all', 'core.symlinks', selectedinstance.username].join(' ')}` |
|
|
, title: `'git', ${['config', '--replace-all', 'core.symlinks', selectedinstance.username].join(' ')}` |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
task.info = { repo } |
|
|
|
|
|
task.errHandler = errHandler |
|
|
|
|
|
task.statuslog = statuslog |
|
|
|
|
|
task.processedArgs = processedArgs |
|
|
|
|
|
task.selectedinstance = selectedinstance |
|
|
|
|
|
task.runtimestamp = runtimestamp |
|
|
|
|
|
task.ENV = ENV |
|
|
|
|
|
if(repodef.requiresElevation) return shell_verse.runElevated( task ) |
|
|
|
|
|
else return shell_verse.runTask( task ) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initTask(task) |
|
|
|
|
|
|
|
|
|
|
|
if(repodef.requiresElevation) { |
|
|
|
|
|
elevatedBatch.push(shell_verse.getElevatedTask( task )); |
|
|
|
|
|
return elevatedBatch[elevatedBatch.length-1] |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
regularBatch.push(shell_verse.getNonElevatedTask( task )) |
|
|
|
|
|
return regularBatch[regularBatch.length-1] |
|
|
|
|
|
} |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
initTask(task) |
|
|
|
|
|
if(repodef.requiresElevation) { |
|
|
|
|
|
elevatedBatch.push(shell_verse.getElevatedTask( task )); |
|
|
|
|
|
return elevatedBatch[elevatedBatch.length-1] |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
regularBatch.push(shell_verse.getNonElevatedTask( task )) |
|
|
|
|
|
return regularBatch[regularBatch.length-1] |
|
|
} |
|
|
} |
|
|
task.info = { repo } |
|
|
|
|
|
task.errHandler = errHandler |
|
|
|
|
|
task.statuslog = statuslog |
|
|
|
|
|
task.processedArgs = processedArgs |
|
|
|
|
|
task.selectedinstance = selectedinstance |
|
|
|
|
|
task.runtimestamp = runtimestamp |
|
|
|
|
|
task.ENV = ENV |
|
|
|
|
|
if(repodef.requiresElevation) return shell_verse.runElevated( task ) |
|
|
|
|
|
else return shell_verse.runTask( task ) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(def.repo) { |
|
|
if(def.repo) { |
|
|
// Single repo case. |
|
|
// Single repo case. |
|
|
if(def.repo.requiresElevation) { |
|
|
if(def.repo.requiresElevation) { |
|
|
getElevatedTask |
|
|
|
|
|
var t1 = function() { |
|
|
var t1 = function() { |
|
|
return performPull(def).then(() => { |
|
|
return performPull(def).then(() => { |
|
|
return true; |
|
|
return true; |
|
|
|
|
|
|
|
|
if(def.elevated){ |
|
|
if(def.elevated){ |
|
|
elevatedpulltasks = function() { |
|
|
elevatedpulltasks = function() { |
|
|
// shell_verse.getElevatedTask( t1 ) |
|
|
// shell_verse.getElevatedTask( t1 ) |
|
|
return any(def.elevated.map((def) => performPull(def))).then(() => { |
|
|
|
|
|
|
|
|
var eBatch = [] |
|
|
|
|
|
def.elevated.map((def) => getPullTask(def, null, null, null, eBatch)) |
|
|
|
|
|
return shell_verse.runElevated(eBatch).then(() => { |
|
|
return true; |
|
|
return true; |
|
|
}).catch((e) => { |
|
|
}).catch((e) => { |
|
|
console.error(e) |
|
|
console.error(e) |