|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Default Config... |
|
|
// Default Config... |
|
|
var reposervers = [ |
|
|
var reposervers = [ |
|
|
'http://git.bbh' |
|
|
|
|
|
, '//172.16.0.27/repos' |
|
|
|
|
|
|
|
|
'http://git.bbh' |
|
|
|
|
|
, 'https://git.bbh.org.in' |
|
|
|
|
|
, '//172.16.0.27/repos' |
|
|
] |
|
|
] |
|
|
var defaultRepoServer = reposervers[0] |
|
|
|
|
|
|
|
|
var defaultRepoServer = reposervers[1] |
|
|
|
|
|
|
|
|
var currentGitAuthUser ; // nodeShellExec('git', ['config', 'user.email']) ... PB : TODO-- get the current gittea username |
|
|
var currentGitAuthUser ; // nodeShellExec('git', ['config', 'user.email']) ... PB : TODO-- get the current gittea username |
|
|
var defaultRepoOwner = 'chess'; |
|
|
var defaultRepoOwner = 'chess'; |
|
|
|
|
|
|
|
|
, 'is-git-repo' : (dir)=>{ |
|
|
, 'is-git-repo' : (dir)=>{ |
|
|
return nodeShellExec('git', ['-C', dir.name, 'rev-parse'], { stdio : 'ignore'}) |
|
|
return nodeShellExec('git', ['-C', dir.name, 'rev-parse'], { stdio : 'ignore'}) |
|
|
} |
|
|
} |
|
|
|
|
|
, 'set-url' : (remotename, url) => { |
|
|
|
|
|
var pushable = processedArgs.pushable || false; |
|
|
|
|
|
remotename = remotename || processedArgs._[1] |
|
|
|
|
|
url = url || processedArgs._[2] |
|
|
|
|
|
var serial_perform_git_seturl = (repo)=>{ |
|
|
|
|
|
var options = { cwd : repo } |
|
|
|
|
|
// console.log(repo) |
|
|
|
|
|
if(pushable) { |
|
|
|
|
|
return [ |
|
|
|
|
|
['git', ['remote', 'set-url', remotename, url + '/' + repo], { cwd : repo }] |
|
|
|
|
|
] |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
console.error('not supported for non-pushable') |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
var x = (args)=>{ |
|
|
|
|
|
return ()=>{ |
|
|
|
|
|
// console.log(args) |
|
|
|
|
|
return nodeShellExec.apply(null, args) |
|
|
|
|
|
} |
|
|
|
|
|
// return Promise.resolve(true) |
|
|
|
|
|
} |
|
|
|
|
|
var perform_git_seturl = (dir)=>{ |
|
|
|
|
|
op['is-git-repo'](dir).then((code)=>{ |
|
|
|
|
|
any( serial_perform_git_seturl(dir.name).map(x) ) |
|
|
|
|
|
}).catch((e)=>{ |
|
|
|
|
|
// console.log('Failed : ' + dir.name) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const { readdir } = require("fs").promises |
|
|
|
|
|
|
|
|
|
|
|
const dirs = async (perform, path) => { |
|
|
|
|
|
for (const dir of await readdir(path || process.cwd(), { withFileTypes: true })) { |
|
|
|
|
|
if (dir.isDirectory()) perform(dir) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
dirs( perform_git_seturl) |
|
|
|
|
|
} |
|
|
, 'add' : (remotename, url, branch) => { |
|
|
, 'add' : (remotename, url, branch) => { |
|
|
var pushable = processedArgs.pushable || false; |
|
|
var pushable = processedArgs.pushable || false; |
|
|
remotename = remotename || processedArgs._[1] |
|
|
remotename = remotename || processedArgs._[1] |
|
|
|
|
|
|
|
|
return pullCmd |
|
|
return pullCmd |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var errors = []; |
|
|
var performPull = (repo) => { |
|
|
var performPull = (repo) => { |
|
|
if(existsSync(repo)) { |
|
|
if(existsSync(repo)) { |
|
|
console.log('pulling ' + repo) |
|
|
console.log('pulling ' + repo) |
|
|
return nodeShellExec.apply(null, getPullCmd(repo)).catch((e)=>{ console.error(e) }) |
|
|
|
|
|
|
|
|
return nodeShellExec.apply(null, getPullCmd(repo)).catch((e)=>{ |
|
|
|
|
|
errors.push({ repo , e}) |
|
|
|
|
|
console.error(e) }) |
|
|
} |
|
|
} |
|
|
else { |
|
|
else { |
|
|
console.log('cloning ' + repo) |
|
|
console.log('cloning ' + repo) |
|
|
|
|
|
|
|
|
inherit : true, shell: true, |
|
|
inherit : true, shell: true, |
|
|
env: process.env |
|
|
env: process.env |
|
|
, runas : processedArgs.runas |
|
|
, runas : processedArgs.runas |
|
|
}).catch((e)=>{ console.error(e) }).then(()=>{ |
|
|
|
|
|
|
|
|
}).catch((e)=>{ |
|
|
|
|
|
errors.push({ repo , e}) |
|
|
|
|
|
console.error(e) |
|
|
|
|
|
}).then(()=>{ |
|
|
|
|
|
|
|
|
return nodeShellExec('git', ['config', '--replace-all' , 'core.symlinks', true], |
|
|
return nodeShellExec('git', ['config', '--replace-all' , 'core.symlinks', true], |
|
|
{ |
|
|
{ |