134 potential bug in beta format - #137
Merged
Merged
Conversation
…ored
Three bugs in the pre-release suffix path:
1. beta_format / rc_format / release_format were never read from config;
the suffixes were hardcoded as ".beta", ".rc", ".release" in cli.py.
2. _clean_version_suffixes only stripped dot-prefixed forms (.beta),
so PEP 440-style attached suffixes (b1, rc2, a1) were left on the
version string, causing build-count parsing to fail and reset to 1.
3. No support for count placeholders like {beta_count} in the format.
Fix:
- config.py: load beta_format / rc_format / release_format (defaults
preserve the existing ".beta" / ".rc" / ".release" behaviour).
- utils.py: extend _clean_version_suffixes to also strip PEP 440-style
suffixes (b1, a1, rc1 etc.); add apply_prerelease_suffix() which
honours {xxx_count} placeholders and auto-increments the counter by
inspecting the current stored version.
- cli.py: replace hardcoded string appends with apply_prerelease_suffix(),
reading the configured format and the current raw version for counting.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- README: document beta_format / rc_format / release_format config keys
and add a Pre-release Versioning examples section
- docs/quickstart.md: correct wrong description ("prefix with beta-");
point to configuration reference
- docs/calendar-versioning-guide.md: replace the Beta/Alpha section with
accurate Pre-release Suffixes section covering both dot-prefixed and
PEP 440 counter forms
- docs/examples/configuration.md: add Pre-release Suffix Formats section
with a quick-reference table and counter-behaviour notes; add commented
keys to both pyproject.toml and bumpcalver.toml example blocks
- examples/pyproject.toml, examples/bumpcalver.toml: add commented
pre-release format hints alongside the existing hybrid versioning hints
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
[a-zA-Z]+\d*$ triggers Sonar's polynomial-runtime warning because the broad character class combined with a +\d* quantifier pair can be flagged as potentially catastrophic even though the classes are disjoint. Replace with an explicit alternation of the known PEP 440 pre-release identifiers (alpha|beta|rc|a|b) so the engine has no ambiguity to explore and backtracking is eliminated. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.



Description
This pull request introduces a feature to configure the suffix format for pre-release versions in the
bumpcalvertool. Three new optional configuration parameters have been added to thebumpcalver.tomlfile:beta_format,rc_format, andrelease_format. These parameters allow users to specify the suffix appended when using--beta,--rc, and--releaseoptions respectively.For example, users can now define custom suffix formats like
{beta_count}for auto-incrementing beta versions,rc{rc_count}for release candidate versions, and a literal.releasesuffix for final release versions. These configurations provide flexibility in defining version suffixes based on specific project requirements.Additionally, the pull request includes updates to the documentation in the
README.mdfile to explain how to configure and use the new suffix formats. Examples are provided to demonstrate the usage of the new configuration options and how they affect the generated versions.Overall, this enhancement improves the customization options for pre-release versioning in the
bumpcalvertool, making it more versatile and adaptable to different project workflows.