jira-prepare-commit-msg icon indicating copy to clipboard operation
jira-prepare-commit-msg copied to clipboard

PROPOSAL: - [feature] New config: useConventionalCommitScope

Open floydspace opened this issue 3 years ago • 2 comments

Hi @bk201-. Thank you for the valuable package which we heavily use. However according to our latest decision about commit format, we found out that jira-prepare-commit-msg is not flexible enough to configure that format. What we need is having Jira ticket number prepended to the conventional commit scope. Following PR adding the additional config property useConventionalCommitScope which works when isConventionalCommit is enabled and simply prepends the number to the exisiting scope or creates one. Consider the PR as discussion initiation if you think this is too verbose an rare case. But in my opinion it's the missing piece. Thank you

floydspace avatar Dec 03 '22 17:12 floydspace

Hi! Could you please add some examples?

As I understand you correctly, you want to inject a JIRA ticket into the scope by the following rules:

  1. If the scope exists, add the JIRA ticket after all scopes: fix(scope1, scope2): message -> fix(scope1, scope2, JIRA-1234): message
  2. If the scope is empty, create the scope with the JIRA ticket: fix: message -> fix(JIRA-1234): message

Something like that?

bk201- avatar Dec 03 '22 19:12 bk201-

@bk201- yes that's right but in current implementation it's prepending to the scopes Examples: fix(scope1, scope2): message -> fix(JIRA-1234, scope1, scope2): message fix(scope1): message -> fix(JIRA-1234, scope1): message fix: message -> fix(JIRA-1234): message but I don't mind to change it to appending after all scopes, seems it's more obvious behaviour

floydspace avatar Dec 03 '22 20:12 floydspace

As an idea we can use the flag to specify append or prepend, like:

useConventionalCommitScope: append

or define a pattern

useConventionalCommitScope: true
conventionalCommitScopePattern: $S, $J

floydspace avatar Dec 03 '22 23:12 floydspace

It will become like a monster. So many overkill options for so little package :)

After adding append/prepend functionality people will want to inject ticket into the middle of scopes.

I more like the idea to use pattern for everything. Now there is an option to replace all occurrences. But it works only for message part. Maybe it would be better to do this for the entire commit message?

Original commit message: fix(scope1, %J, scope2): Dummy commit message After applying inject pattern [%J] %M: fix(scope1, %J, scope2): [JIRA-1234] Dummy commit message After finale replacing: fix(scope1, JIRA-1234, scope2): [JIRA-1234] Dummy commit message

bk201- avatar Dec 04 '22 10:12 bk201-

We could use 2 patterns, for conventional commits and normal commits:

‘conventionalCommitMessagePattern: %T(%S, %J): %M’ ‘messagePattern: (%J) %M’ But it sounds like a major change

Anyway seems like we can make our own script based on your implementation. Just wanted it Incapacitated

On Sun, 4 Dec 2022 at 11:05, Dmitry Shilov @.***> wrote:

It will become like a monster. So many overkill options for so little package :)

After adding append/prepend functionality people will want to inject ticket into the middle of scopes.

I more like the idea to use pattern for everything. Now there is an option to replace all occurrences. But it works only for message part. Maybe it would be better to do this for the entire commit message?

Original commit message: fix(scope1, %J, scope2): Dummy commit message After applying inject pattern [%J] %M: fix(scope1, %J, scope2): [JIRA-1234] Dummy commit message After finale replacing: fix(scope1, JIRA-1234, scope2): [JIRA-1234] Dummy commit message

— Reply to this email directly, view it on GitHub https://github.com/bk201-/jira-prepare-commit-msg/pull/552#issuecomment-1336365732, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHQ2HEV5WYIKY4E2KHALRDWLRUHDANCNFSM6AAAAAASS3PEDU . You are receiving this because you authored the thread.Message ID: @.***>

floydspace avatar Dec 04 '22 12:12 floydspace

Covered the use case with the following fork https://github.com/floydspace/jira-prepare-conventional-commit-msg Thank you again for the solid basis @bk201-, братан.

floydspace avatar Dec 22 '22 00:12 floydspace