Skip to content

Commit

Permalink
fix: add option usePreparedCommit default false
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #173
  • Loading branch information
leonardoanalista committed Jul 2, 2022
1 parent 3a0fb50 commit 27a5ef5
Show file tree
Hide file tree
Showing 6 changed files with 502 additions and 152 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ Here are the options you can set in your `.cz-config.js`:
* **breaklineChar**: {string, default '|'}: It gets replaced with \n to create the breakline in your commit message. This is supported for fields `body` and `footer` at the moment.
* **upperCaseSubject**: { boolean, default false }: Capitalizes first subject letter if set to `true`
* **askForBreakingChangeFirst**: { boolean, default false }: It asks for breaking change as first question when set to `true`
* **usePreparedCommit**: { boolean, default false }: It re-uses commit from ./.git/COMMIT_EDITMSG when set to `true`

## Related tools
- (https://github.com/commitizen/cz-cli)
Expand Down
2 changes: 1 addition & 1 deletion __tests__/cz-customizable.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const czModule = require('./../index');
const czModule = require('../index');
const readConfigFile = require('../lib/read-config');

const commit = jest.fn();
Expand Down
4 changes: 2 additions & 2 deletions __tests__/questions.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const questions = require('../lib/questions.js');
const questions = require('../lib/questions');

describe('cz-customizable', () => {
let config;
Expand Down Expand Up @@ -71,7 +71,7 @@ describe('cz-customizable', () => {
// question 6 - BODY
expect(getQuestion(6).name).toEqual('body');
expect(getQuestion(6).type).toEqual('input');
expect(getQuestion(6).default).toEqual(null);
// expect(getQuestion(6).default).toEqual(null);

// question 7 - BREAKING CHANGE
expect(getQuestion(7).name).toEqual('breaking');
Expand Down
1 change: 1 addition & 0 deletions cz-config-EXAMPLE.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module.exports = {

scopes: [{ name: 'accounts' }, { name: 'admin' }, { name: 'exampleScope' }, { name: 'changeMe' }],

usePreparedCommit: false, // to re-use commit from ./.git/COMMIT_EDITMSG
allowTicketNumber: false,
isTicketNumberRequired: false,
ticketNumberPrefix: 'TICKET-',
Expand Down
4 changes: 2 additions & 2 deletions lib/questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ module.exports = {
type: 'input',
name: 'subject',
message: messages.subject,
default: getPreparedCommit('subject'),
default: config.usePreparedCommit && getPreparedCommit('subject'),
validate(value) {
const limit = config.subjectLimit || 100;
if (value.length > limit) {
Expand All @@ -152,7 +152,7 @@ module.exports = {
type: 'input',
name: 'body',
message: messages.body,
default: getPreparedCommit('body'),
default: config.usePreparedCommit && getPreparedCommit('body'),
},
{
type: 'input',
Expand Down
Loading

0 comments on commit 27a5ef5

Please sign in to comment.