Skip to content

config, version_variables: allow @ as separator and v to precede the version #1185

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

Merged
merged 4 commits into from
Feb 17, 2025

Conversation

benedikt-hess-km
Copy link
Contributor

@benedikt-hess-km benedikt-hess-km commented Feb 12, 2025

Purpose

As discussed in #1156 and #846, this adds two features to the version_variables configuration:

  1. allow the @ separator between the search string and the version within the files
  2. allow a single "v" without any spaces to precede the version

E.g. when running psr with the following configuration

[tool.semantic_release]
version_variables = ["my-versions.txt:version"]

and there is a my-versions.txt with content

version@v1.2.3

and the new version is 2.3.4 the content of my-versions.txt will be:

version@v2.3.4

Rationale

Simple adaption of the regex did the trick

How did you test?

Unittesting was not easy as the implementation was entangled with other code. Therefore I did multiple commits:

  • 49a9366 -> adapt the regex. This is the whole implementation of the features
  • c3804fe -> documentation
  • 47afae9 -> here i entangled the regex building from the config parsing. This way i was able to test the module on its own
  • 456a2bf -> contains the unittests. This is my first time working with pytest. If i did something wrong, please let me know

Regarding the e2e tests: The tests are massive. I don't know where (and how i can expand those). I you point me to the right direction, i will add those tests.

How to Verify

The new documentation gives an example how to configure


PR Completion Checklist

  • Reviewed & followed the Contributor Guidelines

  • Changes Implemented & Validation pipeline succeeds

  • Commits follow the Conventional Commits standard
    and are separated into the proper commit type and scope (recommended order: test, build, feat/fix, docs)

  • Appropriate Unit tests added/updated

  • Appropriate End-to-End tests added/updated

  • Appropriate Documentation added/updated and syntax validated for sphinx build (see Contributor Guidelines)

@benedikt-hess-km
Copy link
Contributor Author

formatted the tests with ruff. all tests should pass now

Copy link
Contributor

@codejedi365 codejedi365 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@benedikt-hess-km, thanks for the great work. I kinda went overboard as I was trying to help fully implement the tag_format support and thanks to you for motivating me to refactor the Declaration classes. I ended up going so far that I had to re-organize the commits to slice out the v? portion you had so I'm sorry that it doesn't look the same any more but I transplanted your authorship to the @ symbol part (just in a different file), tests, and docs.

@codejedi365 codejedi365 merged commit 23f69b6 into python-semantic-release:master Feb 17, 2025
12 checks passed
@benedikt-hess-km
Copy link
Contributor Author

I am glad i could help! Don't worry about refactoring my code! The whole reason i spitted my proposed changes into multiple commits was so you could pick whatever you liked!

@codejedi365
Copy link
Contributor

🎉 This PR has been published as part of Version 9.20.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
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add @ to allowed separators of version_variables
2 participants