Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed May 11, 2020
2 parents 51b4555 + eb04587 commit 07d0088
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 16 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ gitm init
# 查看配置
gitm config list [option]
# 版本升级[-m --mirror]使用淘宝镜像升级
gitm upgrade --mirror
# 查看版本
gitm -v
Expand Down Expand Up @@ -86,7 +89,7 @@ gitm merge 20001
gitm copy release xxxxxx xxxxxx xxxxxx
```

2. 传入查询关键词,gitm会根据提供的关键词(目前限制关键词必须是4位以上的数字,可以是任务号或者bug编号),在对应分支的提交记录里面搜索提交记录并自动执行copy指令
2. 传入查询关键词,gitm会根据提供的关键词(为确保copy准确,请尽量完整填写关键词),在对应分支的提交记录里面搜索提交记录并自动执行copy指令
```
# 指令形式:gitm copy <from> [-k --key] [-a --author]
gitm copy dev --key 100000 --author saqqdy
Expand Down
11 changes: 6 additions & 5 deletions bin/gitm-copy.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env node
const program = require('commander')
const sh = require('shelljs')
const { error, success, queue, getStatus, getCurrent } = require('./index')
const { error, warning, success, queue, getStatus, getCurrent } = require('./index')
/**
* gitm copy
*/
Expand All @@ -18,10 +18,11 @@ program
if (!status) sh.exit(1)
if (opts.key !== '' || opts.author !== '') {
let cmd = [`git checkout ${from}`, `git log --grep=${opts.key} --author=${opts.author}`]
if (!/^\d{4,}$/.test(opts.key)) {
sh.echo(error('为确保copy准确,关键词必须是4位以上的任务号或者bug修复编号'))
sh.exit(1)
}
sh.echo(warning('为确保copy准确,请尽量完整填写关键词'))
// if (!/^\d{4,}$/.test(opts.key)) {
// sh.echo(error('为确保copy准确,关键词必须是4位以上的任务号或者bug修复编号'))
// sh.exit(1)
// }
queue(cmd).then(data => {
let commits = []
if (data[1].code === 0) {
Expand Down
12 changes: 10 additions & 2 deletions bin/gitm-upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@ program
let cmd = [
{
cmd: `npm install -g gitmars ${opt.mirror ? '--registry=https://registry.npm.taobao.org' : ''}`,
config: { slient: false, again: true, success: '升级成功', fail: '升级失败,请重试' }
config: { slient: false, again: true, kill: false, success: '升级成功', fail: '升级失败,请重试' }
},
{
cmd: `gitm -v`,
config: { slient: true, again: false }
}
]
queue(cmd)
queue(cmd).then(data => {
if (data[0].code === 0) {
sh.echo(data[1].out)
}
})
})
program.parse(process.argv)
15 changes: 8 additions & 7 deletions bin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,14 @@ const queue = list => {
sh.exit(1)
} else {
if (code === 0) {
sh.echo(success(config.success || msg.success || '指令 ' + cmd + ' 执行成功'))
config.postmsg && postMessage(config.success || msg.success || '指令 ' + cmd + ' 执行成功')
let m = config.success || msg.success
if (m) {
sh.echo(success(m))
config.postmsg && postMessage(m)
}
} else {
sh.echo(warning(config.fail || msg.fail || '指令 ' + cmd + ' 执行失败'))
let m = config.fail || msg.fail || '指令 ' + cmd + ' 执行失败'
m && sh.echo(warning(m))
}
cb() // 回调,继续执行吓一条
}
Expand Down Expand Up @@ -265,10 +269,7 @@ const getMessage = type => {
* @description 获取通用的指令提示信息
*/
const getCommandMessage = cmd => {
let msg = {
success: '执行成功',
fail: '执行失败'
},
let msg = {},
arr = cmd.replace(/[\s]+/g, ' ').split(' ')
if (arr.length < 2 || arr[0] !== 'git') return msg
switch (arr[1]) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "gitmars",
"description": "git tool for newbees",
"version": "1.0.17",
"version": "1.0.18",
"main": "bin/gitm.js",
"scripts": {
"start": "react-scripts start"
Expand Down

0 comments on commit 07d0088

Please sign in to comment.