Skip to content

fix(version): increase version_variable flexibility w/ quotes (ie. json, yaml, etc) #1028

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 Sep 23, 2024

Purpose

Rationale

Previously json would not work due to the key being wrapped in quotes and therefore the regex would not match
The previous generated regex also has issues with yaml when it does not usually use quotes. The regex originally only wrapped the version to be replaced in quotes (for example: version = "1.2.3") but now both the key and version can optionally be wrapped in different kind of quotations.

I also ended up adding a small negative lookbehind to make sure that our pattern matcher did not match on suffixes of other variable names (ex. cff-version).

How did you test?

I tested json with a single key of the word version which was not supported before unless " were provided. Secondly, I tested yaml where the version did not have quotes around the version. The rest were to validate the capability was maintained for python. I added 4 test cases that replicate the stamping of files of different formats and names. Each test will load the files into memory to ensure they are parsed properly as well that they didn't cause any additional modifications.

How to Verify

pytest -k test_stamp_version_variables

… (ie. json, yaml, etc)

Previously json would not work due to the key being wrapped in quotes, yaml also has issues
when it does not usually use quotes. The regex we created originally only wrapped the version
to be replaced in quotes but now both the key and version can optionally be wrapped in
different kind of quotations.

Resolves: python-semantic-release#601, python-semantic-release#706, python-semantic-release#962, python-semantic-release#1026
@codejedi365 codejedi365 force-pushed the fix/version-variable-quote-flexibility branch from 7b29ae7 to b339b6d Compare September 27, 2024 06:33
@codejedi365 codejedi365 merged commit 156915c into python-semantic-release:master Sep 27, 2024
9 checks passed
@codejedi365 codejedi365 deleted the fix/version-variable-quote-flexibility branch September 27, 2024 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant