jira-precommit-hook
Version:
Git commit hook to verify commit messages are tagged with a JIRA issue number
66 lines (46 loc) • 2.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
exports.isWorkEmail = isWorkEmail;
var _chalk = require('chalk');
var _chalk2 = _interopRequireDefault(_chalk);
var _childProcessPromise = require('child-process-promise');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function isWorkEmail(email) {
return (/@(extendhealth|towerswatson|willistowerswatson)\.com/i.test(email)
);
}
exports.default = function () {
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee() {
var _ref2, stdout, email, message;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return (0, _childProcessPromise.exec)('git config --get user.email');
case 2:
_ref2 = _context.sent;
stdout = _ref2.stdout;
email = stdout.trim();
if (!isWorkEmail(email)) {
message = _chalk2.default.yellow('WARNING: The email address you have configured in Git, \'' + email + '\', is not ' + 'your work email address. To configure your work email address for this ' + 'repo run:\n\n') + _chalk2.default.green('> git config user.email "<Work Email Here>"') + _chalk2.default.yellow('\n\nTo configure your work email address for all repos run: (You may ' + 'want to remember to use your personal email address for any open source ' + 'repos with this option, so choose the option that works best for you.)\n\n') + _chalk2.default.green('> git config user.email "<Work Email Here>" --global\n');
console.log(message);
}
case 6:
case 'end':
return _context.stop();
}
}
}, _callee, this);
}));
function checkUserEmail() {
return _ref.apply(this, arguments);
}
return checkUserEmail;
}();