Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add work CLOSED ISSUES automatically #25

Merged
merged 1 commit into from
Mar 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Suitable for large teams working with multiple projects with their own commit sc

* Run `cp ./node_modules/cz-customizable/cz-config-EXAMPLE.js ./.cz-config.js` in a project root directory to get a template.

**Notes:**
* you should commit your `.cz-config.js` file to your git.
**Notes:**
* you should commit your `.cz-config.js` file to your git.
* if you don't provide a config file, this adapter will use the contents of the default file `node_modules/cz-customizable/cz-config-EXAMPLE.js`


Expand All @@ -41,7 +41,7 @@ Hopefully this will help you to have consistent commit messages and have a fully
Here are the options you can set in your `.cz-config.js`:

* scopes: {Array of Strings}: Specify the scopes for your particular project. Eg.: for some banking system: ["acccounts", "payments"]. For another travelling application: ["bookings", "search", "profile"]
* scopeOverrides: {Object where key contains a Array of String}: Use this when you want to override scopes for a specific commit type. Example bellow specify scopes when type is `fix`:
* scopeOverrides: {Object where key contains a Array of String}: Use this when you want to override scopes for a specific commit type. Example bellow specify scopes when type is `fix`:
```
scopeOverrides: {
fix: [
Expand Down Expand Up @@ -87,4 +87,5 @@ Please refer to the [Contributor Guidelines](https://github.com/angular/angular.




Leonardo Correa
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function buildCommit(answers) {
result += '\n\n' + 'BREAKING CHANGE:\n' + breaking;
}
if (footer) {
result += '\n\n' + footer;
result += '\n\nISSUES CLOSED: ' + footer;
}

return escapeSpecialChars(result);
Expand All @@ -99,13 +99,13 @@ module.exports = {
{
type: 'list',
name: 'type',
message: '\nSelect the type of change that you\'re committing:',
message: 'Select the type of change that you\'re committing:',
choices: config.types
},
{
type: 'list',
name: 'scope',
message: '\nDenote the SCOPE of this change (optional):\n',
message: '\nDenote the SCOPE of this change (optional):',
choices: function(answers) {
var scopes = [];
if (config.scopeOverrides[answers.type]) {
Expand Down Expand Up @@ -140,15 +140,15 @@ module.exports = {
{
type: 'input',
name: 'scope',
message: '\nDenote the SCOPE of this change:\n',
message: 'Denote the SCOPE of this change:',
when: function(answers) {
return answers.scope === 'custom';
}
},
{
type: 'input',
name: 'subject',
message: '\nWrite a SHORT, IMPERATIVE tense description of the change:\n',
message: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
validate: function(value) {
return !!value;
},
Expand All @@ -159,12 +159,12 @@ module.exports = {
{
type: 'input',
name: 'body',
message: '\nProvide a LONGER description of the change (optional). Use "|" to break new line:\n'
message: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n'
},
{
type: 'input',
name: 'breaking',
message: '\nList any BREAKING CHANGES (optional):\n',
message: 'List any BREAKING CHANGES (optional):\n',
when: function(answers) {
if (config.allowBreakingChanges) {
return config.allowBreakingChanges.indexOf(answers.type.toLowerCase()) >= 0;
Expand All @@ -176,7 +176,7 @@ module.exports = {
{
type: 'input',
name: 'footer',
message: '\nList any ISSUES CLOSED by this change (optional):\n',
message: 'List any ISSUES CLOSED by this change (optional). E.g.: #31, #34:\n',
when: isNotWip
},
{
Expand Down
9 changes: 6 additions & 3 deletions spec/czCustomizableSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('cz-customizable', function() {
};

commitAnswers(answers);
expect(commit).toHaveBeenCalledWith('feat(myScope): create a new cool feature\n\n-line1\n-line2\n\nBREAKING CHANGE:\nbreaking\n\nmy footer');
expect(commit).toHaveBeenCalledWith('feat(myScope): create a new cool feature\n\n-line1\n-line2\n\nBREAKING CHANGE:\nbreaking\n\nISSUES CLOSED: my footer');
});

it('should call commit() function with commit message with the minimal required fields', function() {
Expand Down Expand Up @@ -207,13 +207,16 @@ describe('cz-customizable', function() {

var chars_100 = '0123456789-0123456789-0123456789-0123456789-0123456789-0123456789-0123456789-0123456789-0123456789-0123456789';

// this string will be prepend: "ISSUES CLOSED: " = 15 chars
var footerChars_100 = '0123456789-0123456789-0123456789-0123456789-0123456789-0123456789-0123456789-0123456789-012345';

var answers = {
confirmCommit: 'yes',
type: 'feat',
scope: 'myScope',
subject: chars_100,
body: chars_100 + ' body-second-line',
footer: chars_100 + ' footer-second-line'
footer: footerChars_100 + ' footer-second-line'
};

commitAnswers(answers);
Expand All @@ -229,7 +232,7 @@ describe('cz-customizable', function() {

//it should wrap footer
var footer = commit.mostRecentCall.args[0].split('\n\n')[2];
expect(footer).toEqual(chars_100 + '\nfooter-second-line');
expect(footer).toEqual('ISSUES CLOSED: ' + footerChars_100 + '\nfooter-second-line');

});

Expand Down