Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed Aug 2, 2020
2 parents 818104e + 36965ee commit b99136c
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 225 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 2020.08.02 v1.3.2更新日志
1. 更换获取当前分支名称的方式,解决Windows环境兼容问题

# 2020.07.23 v1.3.1更新日志
1. 优化link/unlink,兼容Windows系统

Expand Down
30 changes: 13 additions & 17 deletions lib/gitm-combine.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var config = require('./js/config');

program.name('gitm combine').usage('[type] [name] [-d --dev] [-p --prod]').arguments('[type] [name]').description('合并bugfix任务分支、合并feature功能开发分支、合并support分支').option('-d, --dev', '是否同步到alpha测试环境', false).option('-p, --prod', '是否同步到预发布环境', false).option('-b, --build [build]', '需要构建的应用').option('-m, --commit [commit]', 'commit信息', '').option('-a, --add', '需要add', false).option('--no-bugfix', '不同步到bug分支').option('--as-feature', 'bug分支合并到release').action(function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(type, name, opt) {
var allow, deny, status, _yield$getCurrent$spl, _yield$getCurrent$spl2, branchs, _branchs$0$split, _branchs$0$split2, base, cmd;
var allow, deny, status, _getCurrent$split, _getCurrent$split2, branchs, _branchs$0$split, _branchs$0$split2, base, cmd;

return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
Expand Down Expand Up @@ -113,31 +113,27 @@ program.name('gitm combine').usage('[type] [name] [-d --dev] [-p --prod]').argum
}

if (type) {
_context.next = 24;
_context.next = 22;
break;
}

;
_context.next = 17;
return getCurrent();

case 17:
_yield$getCurrent$spl = _context.sent.split('/');
_yield$getCurrent$spl2 = _slicedToArray(_yield$getCurrent$spl, 2);
type = _yield$getCurrent$spl2[0];
name = _yield$getCurrent$spl2[1];
_getCurrent$split = getCurrent().split('/');
_getCurrent$split2 = _slicedToArray(_getCurrent$split, 2);
type = _getCurrent$split2[0];
name = _getCurrent$split2[1];

if (!name) {
deny.includes(type) && sh.echo(error("\u9A9A\u5E74\uFF0C\u4F60\u5728".concat(type, "\u5206\u652F\u6267\u884C\u8FD9\u4E2A\u6307\u4EE4\u662F\u4EC0\u4E48\u9A9A\u64CD\u4F5C\uFF1F")));
sh.exit(1);
}

_context.next = 30;
_context.next = 28;
break;

case 24:
case 22:
if (name) {
_context.next = 30;
_context.next = 28;
break;
}

Expand All @@ -146,10 +142,10 @@ program.name('gitm combine').usage('[type] [name] [-d --dev] [-p --prod]').argum
sh.exit(1);
}

_context.next = 28;
_context.next = 26;
return searchBranch(type);

case 28:
case 26:
branchs = _context.sent;

if (branchs.length === 1) {
Expand All @@ -163,7 +159,7 @@ program.name('gitm combine').usage('[type] [name] [-d --dev] [-p --prod]').argum
sh.exit(1);
}

case 30:
case 28:
if (allow.includes(type) && name) {
base = type === 'bugfix' ? config.bugfix : config.release, cmd = [];

Expand Down Expand Up @@ -299,7 +295,7 @@ program.name('gitm combine').usage('[type] [name] [-d --dev] [-p --prod]').argum
sh.exit(1);
}

case 31:
case 29:
case "end":
return _context.stop();
}
Expand Down
8 changes: 2 additions & 6 deletions lib/gitm-copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@ program.name('gitm copy').usage('<from> [commitid...] [-k] [-a]').arguments('<fr

case 2:
status = _context.sent;
_context.next = 5;
return getCurrent();

case 5:
cur = _context.sent;
cur = getCurrent();
if (!status) sh.exit(1);

if (opts.key !== '' || opts.author !== '') {
Expand Down Expand Up @@ -123,7 +119,7 @@ program.name('gitm copy').usage('<from> [commitid...] [-k] [-a]').arguments('<fr
queue(_cmd);
}

case 8:
case 6:
case "end":
return _context.stop();
}
Expand Down
30 changes: 13 additions & 17 deletions lib/gitm-end.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var _require2 = require('./js/global'),

program.name('gitm end').usage('[type] [name]').arguments('[type] [name]').description('合并bugfix任务分支、合并feature功能开发分支,合并完成后将删除对应分支').action(function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(type, name, opt) {
var allow, deny, status, _yield$getCurrent$spl, _yield$getCurrent$spl2, branchs, _branchs$0$split, _branchs$0$split2, base, cmd;
var allow, deny, status, _getCurrent$split, _getCurrent$split2, branchs, _branchs$0$split, _branchs$0$split2, base, cmd;

return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
Expand All @@ -87,31 +87,27 @@ program.name('gitm end').usage('[type] [name]').arguments('[type] [name]').descr
if (!status) sh.exit(1);

if (type) {
_context.next = 17;
_context.next = 15;
break;
}

;
_context.next = 10;
return getCurrent();

case 10:
_yield$getCurrent$spl = _context.sent.split('/');
_yield$getCurrent$spl2 = _slicedToArray(_yield$getCurrent$spl, 2);
type = _yield$getCurrent$spl2[0];
name = _yield$getCurrent$spl2[1];
_getCurrent$split = getCurrent().split('/');
_getCurrent$split2 = _slicedToArray(_getCurrent$split, 2);
type = _getCurrent$split2[0];
name = _getCurrent$split2[1];

if (!name) {
deny.includes(type) && sh.echo(error("\u9A9A\u5E74\uFF0C\u4F60\u5728".concat(type, "\u5206\u652F\u6267\u884C\u8FD9\u4E2A\u6307\u4EE4\u662F\u4EC0\u4E48\u9A9A\u64CD\u4F5C\uFF1F")));
sh.exit(1);
}

_context.next = 23;
_context.next = 21;
break;

case 17:
case 15:
if (name) {
_context.next = 23;
_context.next = 21;
break;
}

Expand All @@ -120,10 +116,10 @@ program.name('gitm end').usage('[type] [name]').arguments('[type] [name]').descr
sh.exit(1);
}

_context.next = 21;
_context.next = 19;
return searchBranch(type);

case 21:
case 19:
branchs = _context.sent;

if (branchs.length === 1) {
Expand All @@ -137,7 +133,7 @@ program.name('gitm end').usage('[type] [name]').arguments('[type] [name]').descr
sh.exit(1);
}

case 23:
case 21:
if (allow.includes(type) && name) {
base = type === 'bugfix' ? config.bugfix : config.release, cmd = ["git fetch", "git checkout ".concat(config.develop), "git pull", {
cmd: "git merge --no-ff ".concat(type, "/").concat(name),
Expand Down Expand Up @@ -200,7 +196,7 @@ program.name('gitm end').usage('[type] [name]').arguments('[type] [name]').descr
sh.exit(1);
}

case 24:
case 22:
case "end":
return _context.stop();
}
Expand Down
17 changes: 3 additions & 14 deletions lib/gitm-get.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,11 @@ program.name('gitm get').usage('[message] [index]').arguments('[message] [index]
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (message) {
_context.next = 4;
break;
}

if (!message) message = getCurrent();
_context.next = 3;
return getCurrent();

case 3:
message = _context.sent;

case 4:
_context.next = 6;
return getStashList(message);

case 6:
case 3:
list = _context.sent;
if (list.length === 0) sh.echo(warning("\u8BE5\u5206\u652F\u6CA1\u6709\u6682\u5B58\u4EFB\u4F55\u6587\u4EF6\uFF01"));
if (index === undefined && list.length > 1) sh.echo(warning("\u8BE5\u5206\u652F\u4E0B\u6709".concat(list.length, "\u6761\u6682\u5B58\u8BB0\u5F55\uFF0C\u9ED8\u8BA4\u6062\u590D\u6700\u8FD1\u7684\u4E00\u6761\u8BB0\u5F55")));
Expand All @@ -65,7 +54,7 @@ program.name('gitm get').usage('[message] [index]').arguments('[message] [index]
}
}]);

case 11:
case 8:
case "end":
return _context.stop();
}
Expand Down
66 changes: 18 additions & 48 deletions lib/gitm-permission.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,8 @@ require("core-js/modules/es.array.index-of");

require("core-js/modules/es.function.name");

require("core-js/modules/es.object.to-string");

require("core-js/modules/es.promise");

require("core-js/modules/es.regexp.exec");

require("regenerator-runtime/runtime");

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

var program = require('commander');

var sh = require('shelljs');
Expand All @@ -31,42 +21,22 @@ var _require = require('./js/index'),

var config = require('./js/config');

program.name('gitm permission').usage('[message]').arguments('[message]').description('校验提交权限').option('--no-verify', '是否需要跳过校验权限', false).option('--dev', '是否限制dev提交', false).option('--release', '是否限制release提交', false).action(function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(message, opt) {
var current, allow, msg, index;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return getCurrent();

case 2:
current = _context.sent;
allow = [config.master], msg = sh.exec('git show', {
silent: true
}).stdout;
if (opt.dev) allow.push(config.develop);
if (opt.release) allow.push(config.release);
index = allow.indexOf(current);

if (index > -1 && !opt.noVerify && msg && msg.indexOf('Merge:') === -1 && msg.indexOf('Merge branch') === -1) {
sh.echo(error("".concat(allow[index], "\u5206\u652F\u4E0D\u5141\u8BB8\u76F4\u63A5\u63D0\u4EA4")));
sh.exit(1);
} else {
sh.exit(0);
}

case 8:
case "end":
return _context.stop();
}
}
}, _callee);
}));

return function (_x, _x2) {
return _ref.apply(this, arguments);
};
}());
program.name('gitm permission').usage('[message]').arguments('[message]').description('校验提交权限').option('--no-verify', '是否需要跳过校验权限', false).option('--dev', '是否限制dev提交', false).option('--release', '是否限制release提交', false).action(function (message, opt) {
var current = getCurrent();
var allow = [config.master],
msg = sh.exec('git show', {
silent: true
}).stdout,
index;
if (opt.dev) allow.push(config.develop);
if (opt.release) allow.push(config.release);
index = allow.indexOf(current);

if (index > -1 && !opt.noVerify && msg && msg.indexOf('Merge:') === -1 && msg.indexOf('Merge branch') === -1) {
sh.echo(error("".concat(allow[index], "\u5206\u652F\u4E0D\u5141\u8BB8\u76F4\u63A5\u63D0\u4EA4")));
sh.exit(1);
} else {
sh.exit(0);
}
});
program.parse(process.argv);
79 changes: 20 additions & 59 deletions lib/gitm-save.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ require("core-js/modules/es.symbol.description");

require("core-js/modules/es.function.name");

require("core-js/modules/es.object.to-string");

require("core-js/modules/es.promise");

require("regenerator-runtime/runtime");

function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }

function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }

var program = require('commander');

var sh = require('shelljs');
Expand All @@ -25,55 +15,26 @@ var _require = require('./js/index'),
queue = _require.queue,
getCurrent = _require.getCurrent;

program.name('gitm save').usage('[message]').arguments('[message]').description('暂存当前分支文件').option('-f, --force', '没有版本的文件也暂存,这会执行git add .', false).action(function () {
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(message, opt) {
var cmd;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (message) {
_context.next = 4;
break;
}

_context.next = 3;
return getCurrent();

case 3:
message = _context.sent;

case 4:
cmd = [{
cmd: "git stash save \"".concat(message, "\""),
config: {
success: '文件暂存成功',
fail: '出错了,请联系管理员'
}
}];

if (opt.force) {
cmd = ['git add .', {
cmd: "git stash save \"".concat(message, "\""),
config: {
success: '文件暂存成功',
fail: '出错了,请联系管理员'
}
}];
}

queue(cmd);

case 7:
case "end":
return _context.stop();
}
program.name('gitm save').usage('[message]').arguments('[message]').description('暂存当前分支文件').option('-f, --force', '没有版本的文件也暂存,这会执行git add .', false).action(function (message, opt) {
if (!message) message = getCurrent();
var cmd = [{
cmd: "git stash save \"".concat(message, "\""),
config: {
success: '文件暂存成功',
fail: '出错了,请联系管理员'
}
}];

if (opt.force) {
cmd = ['git add .', {
cmd: "git stash save \"".concat(message, "\""),
config: {
success: '文件暂存成功',
fail: '出错了,请联系管理员'
}
}, _callee);
}));
}];
}

return function (_x, _x2) {
return _ref.apply(this, arguments);
};
}());
queue(cmd);
});
program.parse(process.argv);
Loading

0 comments on commit b99136c

Please sign in to comment.