Skip to content

fix(changelog): fixes PSR release commit exclusions for customized commit messages #1139

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

Conversation

codejedi365
Copy link
Contributor

@codejedi365 codejedi365 commented Jan 12, 2025

Purpose

  • Fix PSR to properly ignore PSR release commit messages when customized

Rationale

I came across this bug when looking into #1136. Although #1136 has a faulty configuration, it ends up I found that PSR was not safely escaping the custom release message prior to making it a regular expression. In this case we could of had a weird bug where the regular expression started to throw an error but most have been silent bugs. The more important situation to cover is when people have modified the commit message to strictly adhere to conventional commits even for their release commits. This can potential add characters for the scope that otherwise have special meanings in regular expressions which then leads to their commit not being ignored. This PR prevents that from happening.

Secondly, this PR also adds some regular expression validation into the configuration validation steps. This should help identify problems early for people.

How did you test?

Added unit tests to handle the validation verification both invalid and valid regular expressions to include different numbers of patterns. In the E2E tests, I added one test that rebuilds the last two releases with setting a custom commit message format. It is then validated that the changelog is the same as the original and does not have the release commit included in the changelog for the previous version. When reviewing the test verification steps below the the 2 init mode changelogs fail because the custom commit message failed to be excluded.

How to Verify

# 1. Check out this PR
git fetch upstream/pull/1139:pr-1139
git checkout --detach pr-1139~3

# 2. Run pytest & observe the failures
pytest -vv -k test_changelog_config_with_
pytest -vv -k test_version_changelog_content_custom_commit_message_excluded_automatically
# Note: in the end-to-end tests, there are 2 passing but that is expected because of
# how Update mode works. It doesn't touch the previous version, which is where a
# release commit will appear.

# 3. Update to the head of the PR
git merge pr-1139

# 4. Run pytest again and all tests are resolved
pytest -vv -k test_changelog_config_with_
pytest -vv -k test_version_changelog_content_custom_commit_message_excluded_automatically

@codejedi365 codejedi365 merged commit f9a2078 into python-semantic-release:master Jan 12, 2025
12 checks passed
@codejedi365 codejedi365 deleted the fix/ignore-psr-version-commits branch January 12, 2025 01:48
@codejedi365
Copy link
Contributor Author

🎉 This PR has been published as part of Version 9.16.0 🎉

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

This was referenced Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant