fix(version): increase version_variable
flexibility w/ quotes (ie. json, yaml, etc)
#1028
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.
Purpose
version_variables
results that can work across multiple languages easilyRationale
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