UNPKG

qspark-deploy

Version:

齐圣园区自动化部署

30 lines (26 loc) 1.22 kB
#!/usr/bin/env node const simpleGit = require('simple-git'); const path = require('path') let targetBranch = '测试自动合并' // 目标分支 let sourceBranch = '园区临时修改' // 这里是主分支 默认是‘园区临时修改’ let repoDir = path.resolve('../') // 仓库根目录 const simplegit = simpleGit(repoDir) const dirArr = path.resolve('./').split(path.sep) const activeProjectName = dirArr[dirArr.length - 1] let tempBranch = 'develop_temp' async function autoMerge() { sourceBranch = process.argv.slice(2, process.argv.length)[0] || sourceBranch; //获取第一个参数当源分支 try { const status = await simplegit.status(); targetBranch = status.current await simplegit.checkout(['-b', tempBranch]); await simplegit.checkout(`origin/${sourceBranch}`, ['--', activeProjectName]); await simplegit.commit(`临时提交分支:${targetBranch},系统:${activeProjectName}`); await simplegit.checkout(targetBranch); await simplegit.mergeFromTo(tempBranch, targetBranch, { '--no-commit': true, '--squash': true }) await simplegit.branch(['-D', tempBranch]) } catch (error) { console.log(error); } } autoMerge()