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 configuration option jiraMode,jiraPrefix #157

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ Here are the options you can set in your `.cz-config.js`:
* **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`

* **jiraMode**: { boolean, default false }: Add jira smart commits when set to `true`. only have `Comment` now. adding... `Workflow command`, `Time Spent`...
* **jiraPrefix**: { string, default 'NULL' }: Project code of jira

## Related tools
- (https://github.com/commitizen/cz-cli)
- (https://github.com/leonardoanalista/corp-semantic-release)
Expand Down
8 changes: 8 additions & 0 deletions buildCommit.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ const addTicketNumber = (ticketNumber, config) => {
return `${ticketNumber.trim()} `;
};

const addJirasBody = (jirasBody, config) => {
const jiraPrefix = _.get(config, 'jiraPrefix', '');
if (!jirasBody) return '#ignore_scan# '; // jira id could be none. So there is '#ignore_scan#'

return `${jiraPrefix}-${jirasBody.trim()} #comment `;
};

const addScope = (scope, config) => {
const separator = _.get(config, 'subjectSeparator', defaultSubjectSeparator);

Expand Down Expand Up @@ -71,6 +78,7 @@ module.exports = (answers, config) => {
// Hard limit this line
// eslint-disable-next-line max-len
const head =
addJirasBody(answers.jirasBody, config) +
addType(answers.type, config) +
addScope(answers.scope, config) +
addTicketNumber(answers.ticketNumber, config) +
Expand Down
9 changes: 9 additions & 0 deletions questions.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ module.exports = {
const scopeOverrides = config.scopeOverrides || {};
const messages = config.messages || {};
const skipQuestions = config.skipQuestions || [];
const jiraPrefix = config.jiraPrefix || 'NULL';

messages.jirasBody = messages.jirasBody || `Enter jira ID(s) (e.g. "0000", message will become "${jiraPrefix}-0000 #comment".): (press enter to skip)\n`;
messages.type = messages.type || "Select the type of change that you're committing:";
messages.scope = messages.scope || '\nDenote the SCOPE of this change (optional):';
messages.customScope = messages.customScope || 'Denote the SCOPE of this change:';
Expand All @@ -67,6 +69,13 @@ module.exports = {
messages.confirmCommit = messages.confirmCommit || 'Are you sure you want to proceed with the commit above?';

let questions = [
{
type: 'input',
name: 'jirasBody',
message: messages.jirasBody,
when: config.jiraMode || false,
default: ''
},
{
type: 'list',
name: 'type',
Expand Down