Closed romain-gsr closed 6 years ago
Found the answer to my question :)
const pattern = {
iconized: {
with: /^(🎨|🔥|🐛)(?:\:\((.*?)\))?\s((?:.*(?=\())|.*)(?:\(#(\d*)\))?/,
without: /^(🎨|🔥|🐛)(?:\((.*?)\))?\s((?:.*(?=\())|.*)(?:\(#(\d*)\))?/
},
encoded: /^(:\w*:)(?:\((.*?)\))?\s((?:.*(?=\())|.*)(?:\(#(\d*)\))?/
}
const iconized = {
with: '🎨:(core) Art\n\nThis is art !\n\nBREAKING CHANGE with former style (resolve #13)',
without: '🎨(core) Art\n\nThis is art !\n\nBREAKING CHANGE with former style (resolve #13)',
}
const encoded = ':art:(core) Art\n\nThis is art !\n\nBREAKING CHANGE with former style (resolve #13)'
const match = (sentence, pattern) => sentence.match(pattern)
const log = (sentence, pattern) => match(sentence, pattern)
? `it matches`
: `it doesn't match`
console.log(`using icon with intermediate colon before scope:`, log(iconized.with, pattern.iconized.with))
console.log(`using icon without intermediate colon before scope:`, log(iconized.without, pattern.iconized.without))
console.log(`using code:`, log(encoded, pattern.encoded))
Actually, using gitmoji-cli
the best pattern would be:
const pattern = /^((🎨|🔥|🐛))\:(?:\((.*?)\))?\s((?:.*(?=\())|.*)(?:\(#(\d*)\))?/
But I'm still looking why I get a ✖ message may not be empty [subject-empty]
because of how gitmoji-cli
format the commit message (extending commitlint-config-gitmoji).
So I finally understood, summarized :
cz-gitmoji-changelog
introduces a colon after the emoji, whereas gitmoji-cli
doesn't (so headerPattern
's RegEx is different).cz-gitmoji-changelog
and gitmoji-cli
doesn't offer in the prompts to specify an optional scope, which conflicts with commitlint-config-gitmoji
's headerPattern
's RegEx.
What would sounds more natural would be to have unified tools based on the same conventions, or overwritable ones.You can pass arbitrary options to conventional-commits-parser
which is used to get structured data out of your input.
I suggest you land your wanted changes on either gitmoji-cli
and cz-gitmoji-changelog
or commitlint-config-gitmoji
.
Hi and first thanks for your amazing lib !
I'm not sure this issue belongs here but that would be cool to be able to get a Shareable commitlint config for gitmoji tools using icons (instead of using codes, which already exists here).
Reason is that, using icons feels better since they get displayed in, for example, the GIT logs or SourceTree instead of some ugly
:code:
string.Of course past the look & feel, in the end what matters the most is to be able to leverage semantic versioning throughout versioning commits messages, so being able to validate messages using this format is mandatory and I felt like this could be a great addition.
Affected packages
Possible Solution
The implementation I bet is quite easy, except for the
headerPattern
part of theparserOpt
. I gave a try this morning but can't find yet why it is parsed correctly and suspects some kind of required string representation of each icon because of encoding.