This repository was archived by the owner on Jan 26, 2026. It is now read-only.
feat: recognize Jira issue keys in commit body - #257
Open
davidalpert wants to merge 1 commit into
Open
Conversation
As outlined in git-chglog#183 it can be useful when following the conventional commit syntax to separate conventional commit type in the subject from work item references which often appear in the commit body or commit footer this commit: - adds a new config option 'jira.issue.key_pattern' which is an optional regex used to match issue keys in the commit subject and body - ensures that the Jira Issue Type does not overwrite a Conventional Commit Type; the 'jira.issue.type_maps' map is only used as a backup when the Conventional Commit Type parsed out of the Subject header is empty - runs the 'jira.issue.key_pattern' regex against both the commit Subject header and the entire commit Body NOTE: the current code assumes that only one Jira work item will be bound to a single commit, and this appears consistent with the spirit of Conventional Commits. I have sometimes found it useful to write a Conventional Commit where one 'fix' can close multiple Jira work items, so a future issue/change might consider updating the model to support multiple Jira work items in a single commit message.
davidalpert
force-pushed
the
gh-183-find-jira-keys-in-commit-body
branch
from
November 20, 2023 23:37
958d81e to
2a7ca9e
Compare
davidalpert
force-pushed
the
gh-183-find-jira-keys-in-commit-body
branch
from
November 21, 2023 16:02
c4be634 to
2a7ca9e
Compare
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this do / why do we need it?
As outlined in #183 it can be useful when following the conventional commit syntax to separate the conventional commit type in the subject from work item references which often appear in the commit body or commit footer
How this PR fixes the problem?
this commit:
adds a new config option `options.jira.issue.key_pattern' which is an optional regex used to match issue keys in the commit subject and body
ensures that the Jira Issue Type does not overwrite a Conventional Commit Type; the 'jira.issue.type_maps' map is only used as a backup when the Conventional Commit Type parsed out of the Subject header is empty
runs the 'jira.issue.key_pattern' regex against both the commit Subject header and the entire commit Body
updates the Jira documentation to document configuration options using the same table-based format as the rest of the configuration options
What should your reviewer look out for in this PR?
I have updated the
TestCommitParserParseWithJiratest andtestdata/gitlog_jira.txtwith a commit message and verification that matches the issue described in #183This logic, formerly in the
commitParser.processHeader(...)method, has been refactored up to thecommitParser.parseCommit(...)method so that it can respectcommit.JiraIssueIDwhether set in theprocessHeader(...)or theprocessBody(...)methods:0Check lists
Additional Comments (if any)
NOTE: the current code assumes that only one Jira work item will be bound to a single commit, and this appears consistent with the spirit of Conventional Commits. I have sometimes found it useful to write a Conventional Commit where one 'fix' can close multiple Jira work items, so a future issue/change might consider updating the model to support multiple Jira work items in a single commit message.
Which issue(s) does this PR fix?
fixes # 183