Browse Source

Fixed Pull tasks for whole instance cases

pull/4/head
AkshaThomas 3 years ago
parent
commit
06cd7b6d43
1 changed files with 40 additions and 12 deletions
  1. 40
    12
      index.js

+ 40
- 12
index.js View File

} }
, getpulltask(def){ , getpulltask(def){


// def can be an instance config
// Or an object with many repos and elevated repos
// Or a single repo ( Either Elevated or normal. )


def = (def ? ( def = (def ? (
def.requiresElevation = true,
def.reqularRepos = def.repos,
def.elevatedRepos = def.elevatedRunasRepos
// def.requiresElevation = true,
// def.repos = def.repos,
// def.elevatedRepos = def.elevatedRunasRepos,
def


) : false) || { ) : false) || {
requiresElevation : true,
reqularRepos : gitRepos,
elevatedRepos : elevatedRunasRepos
repos : repomanifest.repos,
elevatedRepos : repomanifest.elevated
} }


var elevatedpulltasks = null;
if(def.repo) {
// Single repo case.
if(def.repo.requiresElevation) {
elevatedpulltasks = function() {
return performPull(def.repo).then(() => {
return true;
}).catch((e) => {
console.error(e)
})
}
return
}
else {
var regularpulltasks = function(){
var pendingpulls = [];
pendingpulls.push(performPull(def.repo))
return Promise.all(pendingpulls).finally(Traq.finally)
}
}
if(elevatedpulltasks) return getTaskWithElevation( { elevatedpulltasks, regularpulltasks} )
else return getTaskWithoutElevation({ regularpulltasks})
}
console.log(`-------------------Processing pull for : ${def.repo} ${def.branch}`)
// console.log(`-------------------Processing pull for : ${def.repo} ${def.branch}`)
console.dir(def) console.dir(def)


var env = Object.assign({}, process.env); // Shallow clone it. var env = Object.assign({}, process.env); // Shallow clone it.


var useGitPull = processedArgs.useGitPull || false; var useGitPull = processedArgs.useGitPull || false;


if(def.elevatedRepos || def.reqularRepos) {
if(def.elevatedRepos || def.repos) {
if(def.elevatedRepos) def.requiresElevation = true; if(def.elevatedRepos) def.requiresElevation = true;
else delete def.requiresElevation; else delete def.requiresElevation;
} }
else { else {
if(def.requiresElevation) def.elevatedRepos = [def] if(def.requiresElevation) def.elevatedRepos = [def]
else def.reqularRepos = [def]
else def.repos = [def]
} }


var elevatedpulltasks = null;
var regularpulltasks = function(){ return Promise.resolve(true) } var regularpulltasks = function(){ return Promise.resolve(true) }
if(def.elevatedRepos){ if(def.elevatedRepos){
elevatedpulltasks = function() { elevatedpulltasks = function() {
}) })
} }
} }
if(def.reqularRepos) {
if(def.repos) {
var regularpulltasks = function(){ var regularpulltasks = function(){
var pendingpulls = []; var pendingpulls = [];
def.reqularRepos.forEach((def) => { pendingpulls.push(performPull(def.repo)) })
def.repos.forEach((def) => { pendingpulls.push(performPull(def.repo)) })
return Promise.all(pendingpulls).finally(Traq.finally) return Promise.all(pendingpulls).finally(Traq.finally)
} }
} }

Loading…
Cancel
Save