Skip to content

Commit

Permalink
chore(pie-monorepo): DSW-000 let commitizen read the ticket number fr…
Browse files Browse the repository at this point in the history
…om the branch name (#1614)

Co-authored-by: Kevin Rodrigues <[email protected]>
  • Loading branch information
xander-marjoram and kevinrodrigues authored Jul 18, 2024
1 parent 7a7805d commit ee0b011
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .changeset/polite-bugs-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"pie-monorepo": minor
---

[Changed] - Let commitizen read ticket number from branch name
11 changes: 9 additions & 2 deletions .cz-config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const fs = require('fs')
const { globSync } = require('glob')


const getPackages = () => {
const ignore = [
'apps/examples/**',
Expand All @@ -22,6 +21,13 @@ const getPackages = () => {
return packageNames;
};

const getCurrentTicketNumberFromBranch = () => {
const branchName = require('child_process').execSync('git rev-parse --abbrev-ref HEAD').toString().trim();
const ticketNumber = branchName.match(/\d{1,7}/)?.[0];

return ticketNumber;
};

module.exports = {
// We have to provide '\u0020' to some emojis due to a spacing bug with commitizen - https://github.com/commitizen/cz-cli/issues/815
types: [
Expand All @@ -45,7 +51,7 @@ module.exports = {
messages: {
type: "Select the type of change that you're committing:",
scope: 'Denote the SCOPE of this change:',
ticketNumber: "Jira ticket number (enter 0 to fill automatically):",
ticketNumber: `Jira ticket number (${getCurrentTicketNumberFromBranch() || '000'}):`,
subject: 'Write a SHORT, IMPERATIVE tense description of the change:',
body: '(optional) Provide a LONGER description of the change. Use "|" to break new line:',
breaking: '(optional) List any BREAKING CHANGES:',
Expand All @@ -55,6 +61,7 @@ module.exports = {
allowCustomScopes: false,
skipQuestions: ['footer'],
allowTicketNumber: true,
fallbackTicketNumber: getCurrentTicketNumberFromBranch() || '000',
isTicketNumberRequired: true,
ticketNumberPrefix: 'DSW-',
ticketNumberRegExp: '\\d{1,7}',
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,7 @@ custom-elements.json
**/src/react.ts
**/stats.html
**/component-statuses.json

# Yalc
.yalc
yalc.lock
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"commitizen": "4.3.0",
"cross-env": "7.0.3",
"cssnano": "5.1.15",
"cz-customizable": "7.1.0",
"cz-customizable": "7.2.1",
"danger": "11.3.0",
"dree": "3.4.5",
"eslint": "8.37.0",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17719,9 +17719,9 @@ __metadata:
languageName: node
linkType: hard

"cz-customizable@npm:7.1.0":
version: 7.1.0
resolution: "cz-customizable@npm:7.1.0"
"cz-customizable@npm:7.2.1":
version: 7.2.1
resolution: "cz-customizable@npm:7.2.1"
dependencies:
editor: 1.0.0
find-config: ^1.0.0
Expand All @@ -17732,7 +17732,7 @@ __metadata:
bin:
cz-cust: standalone.js
cz-customizable: standalone.js
checksum: b8ce92e6aa84fb0c2d921d9cc676b032e12176fd850e384a71a9a6cf21d079d731d8b5364ad0aeb894df4538b0fee091cd21710900c005679646706cda3049b6
checksum: 60d32287fc94e3ff0c17615d28adc704d37a054a518a72e3f7fb82fcaa0de72865a7dbb09f5f4ed92802e0729aac97b651de97e82fac477ccad0f10cab4110b4
languageName: node
linkType: hard

Expand Down Expand Up @@ -29764,7 +29764,7 @@ __metadata:
commitizen: 4.3.0
cross-env: 7.0.3
cssnano: 5.1.15
cz-customizable: 7.1.0
cz-customizable: 7.2.1
danger: 11.3.0
dree: 3.4.5
eslint: 8.37.0
Expand Down

0 comments on commit ee0b011

Please sign in to comment.