You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit parsers to handle merge commit prefixes #540
When you merge a PR within Azure DevOps, a prefix (Merged PR 12345:) is added to the commit message unless you manually remove it for every PR, leading to commit messages like:
Merged PR 541234: chore: Improve linting
Is there any way to specify a prefix regex to ignore when parsing commits or any other way to handle this case without requiring contributors to dig into the advanced merge options for every PR?
Thanks for bringing this up - I don't think this is currently possible, but I think it would be a nice feature to have - a short term workaround would be to write a custom commit parser, but from the issue you referenced above it seems like this is something that multiple VCS do so it would be nice to have that option.
Adding an option to the commit parsers for an "optional merge commit pattern" which can be stripped should manage this.
fromsemantic_release.historyimportangular_parserfromsemantic_release.history.parser_helpersimportParsedCommitMERGE_COMMIT_PREFIX="Merge pull request"defparse_commit_message(message: str) ->ParsedCommit:
"""Extends the `angular_parser` function to work with merge commits. Merge commits are not processed by `angular_parser` as they don't adhere to the conventional commit format. Given that we enforce pull request titles to follow this format, this custom parser is required to ensure these PR titles are usable by `python-semantic-release`. If a commit message starts with `MERGE_COMMIT_PREFIX` then it's considered a merge commit and the last line of the commit message will be extracted (this should be the original PR title) and sent to `angular_parser`. Example merge commit message: ``` Merge pull request #553 from octocat/feature-x feat: enable feature X ``` Args: message: A git commit message. Returns: A `ParsedCommit` object containing semantic release version and changelog information. """message=message.strip() # remove leading/trailing blank linesifmessage.startswith(MERGE_COMMIT_PREFIX):
message=message.splitlines()[-1]
message=message.strip() # remove leading/trailing whitespacereturnangular_parser(message)
It has been 60 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?
Not sure if this helps but ended up creating a custom parser to work with Azure Devops merge commits. Hope this is useful until a dedicated option is available for prefix handling... just note that in this case I am using Poetry with pyproject.toml, so the tag configuration is being retrieved from here.
It has been 60 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?
A generalized approach for having different options for what to do with merge commits would be helpful. At my org we annotate each commit fully, so the messages in the merge commits are actually redundant and I'd like to simply skip them when generating the CHANGELOG.
@mikenerone, I agree. You can see an example in PSR's project configuration. Merge commits are completely ignored using the changelog.exclude_commit_patterns.
Unless there is a compelling reason, I move to close this feature request because ultimately your merge commits are nothing but duplicates of commits already in the git tree. If you are using semantic commits as they are intended then the changes are already documented and merge commits should just be excluded using the pattern matches. I may in the future include a simple Boolean to identify and filter out merge commits but until then the pattern exclusion is the recommended method for handling merge commits in history.
Activity
[-]Azure DevOps Squash Merge prefixes[/-][+]Azure DevOps merge commit prefixes[/+]bernardcooke53 commentedon Jan 15, 2023
Hi @TGNThump,
Thanks for bringing this up - I don't think this is currently possible, but I think it would be a nice feature to have - a short term workaround would be to write a custom commit parser, but from the issue you referenced above it seems like this is something that multiple VCS do so it would be nice to have that option.
Adding an option to the commit parsers for an "optional merge commit pattern" which can be stripped should manage this.
[-]Azure DevOps merge commit prefixes[/-][+]Commit parsers to handle merge commit prefixes[/+]manudawber commentedon May 23, 2023
For anyone facing this with GitHub merge commits:
github-actions commentedon May 29, 2024
It has been 60 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?
codejedi365 commentedon May 29, 2024
No update yet, still in the backlog
lawrenceeldridge commentedon Jun 2, 2024
Not sure if this helps but ended up creating a custom parser to work with Azure Devops merge commits. Hope this is useful until a dedicated option is available for prefix handling... just note that in this case I am using Poetry with pyproject.toml, so the tag configuration is being retrieved from here.
github-actions commentedon Aug 8, 2024
It has been 60 days since the last update on this confirmed issue. @python-semantic-release/team can you provide an update on the status of this issue?
mikenerone commentedon Aug 17, 2024
A generalized approach for having different options for what to do with merge commits would be helpful. At my org we annotate each commit fully, so the messages in the merge commits are actually redundant and I'd like to simply skip them when generating the CHANGELOG.
codejedi365 commentedon Aug 17, 2024
@mikenerone, I agree. You can see an example in PSR's project configuration. Merge commits are completely ignored using the
changelog.exclude_commit_patterns.codejedi365 commentedon Aug 17, 2024
Unless there is a compelling reason, I move to close this feature request because ultimately your merge commits are nothing but duplicates of commits already in the git tree. If you are using semantic commits as they are intended then the changes are already documented and merge commits should just be excluded using the pattern matches. I may in the future include a simple Boolean to identify and filter out merge commits but until then the pattern exclusion is the recommended method for handling merge commits in history.
github-actions commentedon Oct 20, 2024
This issue has not received a response in 14 days. If no response is received in 7 days, it will be closed. We look forward to hearing from you.
github-actions commentedon Oct 28, 2024
This issue was closed because no response was received.