Browse Source

Merge branch 'master' of JArun2018/elxr into master

pull/3/head
pb 4 years ago
parent
commit
1fe48e926a
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      index.js

+ 8
- 4
index.js View File

, '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'})
} }
, 'add' : (remotename, url) => {
, 'add' : (remotename, url, branch) => {
remotename = remotename || processedArgs._[1] remotename = remotename || processedArgs._[1]
url = url || processedArgs._[2] url = url || processedArgs._[2]
var branch = 'master';
branch = branch || processedArgs._[3]
var serial_perform_git_add = (repo)=>{ var serial_perform_git_add = (repo)=>{
var options = { cwd : repo } var options = { cwd : repo }
// console.log(repo) // console.log(repo)
return [ return [
['git', ['remote', 'add', remotename, url + '/' + repo], { cwd : repo }] ['git', ['remote', 'add', remotename, url + '/' + repo], { cwd : repo }]
, ['git', ['remote', `set-url`, '--push', remotename, 'no-pushing'], { cwd : repo }]
, ['git', ['pull', remotename, branch], { cwd : repo }] , ['git', ['pull', remotename, branch], { cwd : repo }]
, ['git', ['branch', `--set-upstream-to=${remotename}/${branch}`, branch], { cwd : repo }] , ['git', ['branch', `--set-upstream-to=${remotename}/${branch}`, branch], { cwd : repo }]
] ]
// console.log(code) // console.log(code)
if(code) { if(code) {
nodeShellExec('git',['remote', 'get-url', remotename], { cwd : dir.name, stdio : 'ignore' }).then(()=>{ nodeShellExec('git',['remote', 'get-url', remotename], { cwd : dir.name, stdio : 'ignore' }).then(()=>{
console.log('skipped : ' + dir.name + ', reason : No remote named origin')
console.log('skipped : ' + dir.name + ', reason : A remote with same name already exists.')
}) })
.catch((e)=>{ .catch((e)=>{
any( serial_perform_git_add(dir.name).map(x) ) any( serial_perform_git_add(dir.name).map(x) )


var useGitPull = processedArgs.useGitPull || false; var useGitPull = processedArgs.useGitPull || false;
var getPullCmd = (repo)=>{ var getPullCmd = (repo)=>{
// console.log(useGitPull)


var pullCmd = ["C:\\Program Files\\Git\\bin\\sh.exe", ['-c', 'branch=`git rev-parse --abbrev-ref HEAD`;for i in `git remote`; do git pull $i $branch; done;'], { cwd : repo }]
var pullCmd = ["C:\\Program Files\\Git\\bin\\sh.exe"
, ['-c', 'branch=`git rev-parse --abbrev-ref HEAD`;for i in `git remote`; do git pull $i $branch; done;']
, { cwd : repo, title : 'pull all origins for ' + repo }]
// var pullCmd = ['pullall', [], { cwd : repo }] // var pullCmd = ['pullall', [], { cwd : repo }]
if(useGitPull) pullCmd = ['git', ['pull'], { if(useGitPull) pullCmd = ['git', ['pull'], {
inherit : true, shell: true, inherit : true, shell: true,

Loading…
Cancel
Save