Skip to content

Commit parser: Add support for squash commits (BitBucket specific) #1085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
adaniline opened this issue Nov 5, 2024 · 4 comments · Fixed by #1112
Closed

Commit parser: Add support for squash commits (BitBucket specific) #1085

adaniline opened this issue Nov 5, 2024 · 4 comments · Fixed by #1112
Assignees
Labels
confirmed Prevent from becoming stale feature A new feature or a feature request

Comments

@adaniline
Copy link

Feature Request

Description

Angular Commit Parser doesn't work with BitBucket multi-line PR commit messages.

BitBucket by default generates commit messages when a pull request merged to master that look like this:

Merged in feat/my-awasome-stuff  (pull request #10)

feat: Implemented searching gizmos by keyword

More description

BitBucket Cloud doesn't allow to customize merge message template.

Angular commit parser uses re.match() which does not match tags on the second line. Using re.search() matches tags on the second line.

Use cases

This will allow to use python-semantic-release with BitBucket cloud.

Possible implementation

Option 1: replace re.match() with re.search() in AngularCommitParser.

Option 2: have a separate parser option to match tags after the first line.

Alternative solutions

n/a

@adaniline adaniline added feature A new feature or a feature request triage waiting for initial maintainer review labels Nov 5, 2024
@adaniline adaniline changed the title Angular commit parser: Support for multi-line BitBucket pull request merge commit message Commit parser: Support for multi-line BitBucket pull request merge commit message Nov 5, 2024
@codejedi365 codejedi365 removed the triage waiting for initial maintainer review label Nov 5, 2024
@codejedi365
Copy link
Contributor

Is this considered an actual merge commit (where the commit has 2 parent commits?) or is it the default squash commit syntax that BitBucket uses?

Firstly, PSR does not support squash commit parsing at this time. It is in work but is not fully tested (and therefore not released yet).

Secondly, It is my recommendation to actually ignore actual merge commits completely. You can read my rationale on issue #540, comment.

@codejedi365 codejedi365 added the awaiting-reply Waiting for response label Nov 5, 2024
@adaniline
Copy link
Author

adaniline commented Nov 5, 2024

BitBucket (BB) supports both merge and squash commits on PR merges. We use squash commit to keep the main branch history clean.

We follow the trunk-based model, with one PR per feature (and therefore one semantic tag). The trunk branch history is squash commits (one per PR), with the commit message that looks like above.

BB does put squashed commits messages below, but they don't have semantic tags in our case.

With this model squash commits are no different from regular commits. We'd like to use them to bump semantic versions and generates a change log.

Giving users an option to match semantic tags after the first line would be very useful for BitBucket users, and people can use this if that makes sense for their use case.

@codejedi365
Copy link
Contributor

codejedi365 commented Nov 5, 2024

As a workaround, you will have to use the merge commit strategy with Bitbucket currently. The parser that supports squash commits will hopefully be released in the upcoming months and it should work for your use case at that time.

There will be an option to toggle on parsing of squash commits added to the parser_options configuration setting. It will need to be set by you as I am not going to set the default to always parse squash commits until the next breaking release.

Although your option 1 & 2 are possible solutions, they would introduce edge cases that do not follow the angular or conventional commit standard as they are specific to starting on the first line of the commit (ie the subject line). The squash commit implementation I am working on deliberately breaks each portion of the commit up by a double newline and then evaluates if the first line matches the commit convention at that point they become arbitrarily different commits within PSR when passed to the changelog. This allows us to handle version determination and changelog formatting correctly. In your case the Merge ... line will just be considered a ParseError object and if you have set exclude_commit_patterns accordingly, it will be ignored.

@codejedi365 codejedi365 added confirmed Prevent from becoming stale and removed awaiting-reply Waiting for response labels Nov 5, 2024
@codejedi365 codejedi365 changed the title Commit parser: Support for multi-line BitBucket pull request merge commit message Commit parser: Add support for squash commits (BitBucket specific) Nov 5, 2024
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Dec 18, 2024
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Dec 18, 2024
@codejedi365 codejedi365 self-assigned this Dec 24, 2024
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Jan 12, 2025
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Jan 12, 2025
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Jan 18, 2025
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Jan 18, 2025
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Jan 20, 2025
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Jan 20, 2025
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Jan 23, 2025
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Jan 24, 2025
codejedi365 added a commit to codejedi365/python-semantic-release that referenced this issue Jan 26, 2025
@codejedi365
Copy link
Contributor

🎉 This issue has been resolved in Version 9.17.0 🎉

You can find more information about this release on the GitHub Releases page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed Prevent from becoming stale feature A new feature or a feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants