From cb80aa6914d506e7c56ce99b3b303f77036f7e85 Mon Sep 17 00:00:00 2001 From: citycide Date: Tue, 17 Jan 2017 13:45:45 -0600 Subject: [PATCH 1/4] feat(engine): add ci skip directive for docs/chore Add `[ci skip]` directive automatically for `docs` and `chore` commit types (unless it was already added by the user). --- engine.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/engine.js b/engine.js index ad1e0304..83e31cc3 100644 --- a/engine.js +++ b/engine.js @@ -32,7 +32,8 @@ module.exports = function (options) { // // By default, we'll de-indent your commit // template and will keep empty lines. - prompter: function(cz, commit) { + prompter: function (cz, commit) { + console.log('\nLine 1 will be cropped at 100 characters. All other lines will be wrapped after 100 characters.\n'); // Let's ask some questions of the user @@ -65,7 +66,7 @@ module.exports = function (options) { name: 'footer', message: 'List any breaking changes or issues closed by this change:\n' } - ]).then(function(answers) { + ]).then(function (answers) { var maxLineWidth = 100; @@ -80,8 +81,15 @@ module.exports = function (options) { var scope = answers.scope.trim(); scope = scope ? '(' + answers.scope.trim() + ')' : ''; + var ending = answers.subject.trim().slice(-9); + var hasSkip = ending === '[ci skip]' || ending === '[skip ci]'; + var addSkip = !hasSkip && (answers.type === 'docs' || answers.type === 'chore'); + // Hard limit this line - var head = (answers.type + scope + ': ' + answers.subject.trim()).slice(0, maxLineWidth); + var head = (answers.type + scope + ': ' + answers.subject.trim()) + .slice(0, addSkip ? maxLineWidth - 10 : maxLineWidth); + + if (addSkip) head += ' [ci skip]'; // Wrap these lines at 100 characters var body = wrap(answers.body, wrapOptions); From 45520e73ce4c27ab025381f827620bcf40c0bce3 Mon Sep 17 00:00:00 2001 From: "greenkeeper[bot]" Date: Thu, 16 Feb 2017 14:23:34 +0000 Subject: [PATCH 2/4] chore(package): update commitizen to version 2.9.6 https://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d6fae469..fe2d2fc5 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "word-wrap": "^1.0.3" }, "devDependencies": { - "commitizen": "2.9.5", + "commitizen": "2.9.6", "semantic-release": "^6.3.2" }, "czConfig": { From 0c1fe147a2c92e8eff491a048d2d9904bde11598 Mon Sep 17 00:00:00 2001 From: Mark Dalgleish Date: Wed, 22 Feb 2017 03:00:30 +1100 Subject: [PATCH 3/4] feat(adapter): Split breaking changes into separate question (#44) BREAKING CHANGE: Breaking changes now automatically include the "BREAKING CHANGE: " prefix. closes #17 --- engine.js | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/engine.js b/engine.js index 83e31cc3..0951fbb3 100644 --- a/engine.js +++ b/engine.js @@ -5,6 +5,12 @@ var map = require('lodash.map'); var longest = require('longest'); var rightPad = require('right-pad'); +var filter = function(array) { + return array.filter(function(x) { + return x; + }); +}; + // This can be any kind of SystemJS compatible module. // We use Commonjs here, but ES6 or AMD would do just // fine. @@ -63,8 +69,12 @@ module.exports = function (options) { message: 'Provide a longer description of the change:\n' }, { type: 'input', - name: 'footer', - message: 'List any breaking changes or issues closed by this change:\n' + name: 'breaking', + message: 'List any breaking changes:\n' + }, { + type: 'input', + name: 'issues', + message: 'List any issues closed by this change:\n' } ]).then(function (answers) { @@ -93,7 +103,15 @@ module.exports = function (options) { // Wrap these lines at 100 characters var body = wrap(answers.body, wrapOptions); - var footer = wrap(answers.footer, wrapOptions); + + // Apply breaking change prefix, removing it if already present + var breaking = answers.breaking.trim(); + breaking = breaking ? 'BREAKING CHANGE: ' + breaking.replace(/^BREAKING CHANGE: /, '') : ''; + breaking = wrap(breaking, wrapOptions); + + var issues = wrap(answers.issues, wrapOptions); + + var footer = filter([ breaking, issues ]).join('\n\n'); commit(head + '\n\n' + body + '\n\n' + footer); }); From e2f0a56dc0e550dfcc56c56bf09a76590a99d30f Mon Sep 17 00:00:00 2001 From: Bo Lingen Date: Tue, 18 Apr 2017 00:42:31 +0000 Subject: [PATCH 4/4] feat(engine): add ci skip prompt (default to true) Add a prompt to allow the user to disable ci skipping when the commit type is `docs` or `chore`. By default the `[ci skip]` tag is added for these types. --- engine.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/engine.js b/engine.js index 0951fbb3..cd45fa9e 100644 --- a/engine.js +++ b/engine.js @@ -55,6 +55,14 @@ module.exports = function (options) { name: 'type', message: 'Select the type of change that you\'re committing:', choices: choices + }, { + type: 'confirm', + name: 'skipCI', + message: 'Should CI (tests or builds) be skipped for this commit?', + default: true, + when: function (answers) { + return answers.type === 'docs' || answers.type === 'chore' + } }, { type: 'input', name: 'scope', @@ -91,9 +99,14 @@ module.exports = function (options) { var scope = answers.scope.trim(); scope = scope ? '(' + answers.scope.trim() + ')' : ''; - var ending = answers.subject.trim().slice(-9); - var hasSkip = ending === '[ci skip]' || ending === '[skip ci]'; - var addSkip = !hasSkip && (answers.type === 'docs' || answers.type === 'chore'); + var hasSkip = ['[ci skip]', '[skip ci]'].some(v => { + return ( + answers.subject.indexOf(v) > -1 || + answers.body.indexOf(v) > -1 + ) + }); + + var addSkip = !hasSkip && answers.skipCI // Hard limit this line var head = (answers.type + scope + ': ' + answers.subject.trim())