- Notifications
You must be signed in to change notification settings - Fork262
feat(cmd-version): add support for partial tags#1115
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
codejedi365 commentedDec 8, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@MatthieuSarter, thanks for all the hard work you have put in here. It looks good and I was not thinking about this kind of feature or how to implement. One suggestion would be to change the configure name to a longer more descriptive name Thanks for adding the descriptions and doc updates and timeline for testing rather than just passing it to me to complete (surprising how many people do this). To help understand the test suite, note there is the tests/ directory that is split into unit & e2e folders and how to run the test suite is documented in Recommend It is probably also worth noting that a I did swap your PR to ready for review to see how your changes currently evaluate in the CI and nothing failed so you effectively added functionality without breaking anything (that we know of) which is awesome. Now we would just be looking for tests that exercise your new functionality (tag creations & updates) and any new ways that it would impact other non-default settings or environments. Good job so far! |
MatthieuSarter commentedDec 8, 2024
@codejedi365 , thanks for your explanation, it will be helpfull to help me add tests :) Regarding the name of the option, I used this name as it is the name I commonly encountered on other projects for naming such tags, especially in the Docker world (see here for instance:https://docs.vmware.com/en/VMware-Tanzu-Application-Catalog/services/main/GUID-apps-tutorials-understand-rolling-tags-containers-index.html ), but if you prefer an other terminology, I'm totally fine with it. Among your two suggestions, I would prefer rolling_partial_tags, which would both indicate that it enable rolling tags and that those tags are based on partial version (as opposed to rolling tags like "latest", without any version infos). |
codejedi365 commentedDec 8, 2024
I appreciate the insight and thought considered for the name. As I continued writing my response I think I have settled on the |
codejedi365 commentedDec 9, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@MatthieuSarter, Thinking about the tests a little more, I think it will be important to verify the following situations:
Question: how would we consider handling a build metadata change release or just a release with build metadata? I feel like we should be creating a "partial" release from the full tag which would result in a Note: I recommend using the fixture |
codejedi365 commentedDec 9, 2024
the force push change was to help resolve the conflict in |
MatthieuSarter commentedFeb 9, 2025
@codejedi365 , just a little message to tell you I didn't forgot about my commitment to add tests to this PR, but I had a tough start of the year (flu, bike crash...) so I didn't have the opportunity to work on it yet. |
codejedi365 commentedFeb 9, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@MatthieuSarter, thanks for the note, I was starting to debate if you would follow through as most just leave it to me to pick up where they left off. I'm glad you haven't. I hope you feel better soon! It sounds like a rough start to 2025 for you--must be frustrating. If you have seen the rebases, I have just been keeping what was written up to date with the latest version as stuff has refactored which should make it easier to pick up from. |
MatthieuSarter commentedMar 19, 2025 • edited by codejedi365
Loading Uh oh!
There was an error while loading.Please reload this page.
edited by codejedi365
Uh oh!
There was an error while loading.Please reload this page.
@codejedi365, I finally had some time to start adding tests 🙂 Not much for now, but it's a start. I used test_version_bump.py::test_version_force_level as reference, and kept only what is pertinent for tag related checks (ie. dropped the check on version update in files, release creation in VCS, etc...). Regarding the way of handling partial tag for prerelease, I think the answer is no update of the partial tags in this cases, as the partial tags should always point to a release, not a prerelease. For now I opted for the same behavior in case of version with build metadata, as for me those versions are not release. But I'm not used to this versioning scheme, so I'm open to discussion about this, creating/updating partial tags up to the patch level also seems to be a reasonable option in this case. |
codejedi365 commentedMar 19, 2025
@MatthieuSarter, Glad to hear!
I would rather you not drop the assertions in e2e tests. In a e2e test of version, they are all pertinent. As I stated above, it is on purpose to have all the checks so we know that this variation doesn't have a weird side impact on something we didn't consider.
I concur that should be the outcome. We will want a test to ensure these do not move.
Build metadata releases are official releases, they just include more specific information (generally the date). Note that the |
3a1f9ca to8862eb9Comparee34abeb toc4fa3c4CompareMatthieuSarter commentedAug 17, 2025
@codejedi365 , I think I covered all the relevant cases now, so I marked the PR as ready for review. Sorry for having taken soooo long :-( |
codejedi365 commentedAug 21, 2025
@MatthieuSarter, thanks for the hard work, I'll try to get this integrated this weekend |
MatthieuSarter commentedSep 28, 2025
@codejedi365 , I just updated the tests to the new e2e infrastructure, to solve the failing tests |
codejedi365 commentedSep 29, 2025
Oh wow, thanks! I didn't mean to leave that on you to accomplish, I have just been busy. But thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Pull Request Overview
This PR adds support for creating and updating partial version tags alongside full semantic version tags. When enabled, tags likev1 andv1.2 are created/updated to point to the same commit as the full version tag (e.g.,v1.2.3).
Key changes:
- Adds
add_partial_tagsconfiguration option (defaults tofalse) - Implements partial tag creation logic in the version command
- Updates tag filtering in
VersionTranslatorto exclude partial tags from version resolution - Adds git operations support for forced tag creation and pushing
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/semantic_release/cli/config.py | Addsadd_partial_tags configuration field toRawConfig and passes it toVersionTranslator |
src/semantic_release/cli/commands/version.py | Implements partial tag creation/update logic and passes config to utilities |
src/semantic_release/version/translator.py | Adds partial tag filtering regex to prevent treating partial tags as version tags |
src/semantic_release/version/version.py | Adds helper methods to generate partial tag names |
src/semantic_release/gitproject.py | Addsforce parameter to tag and push operations for updating existing tags |
docs/configuration/configuration.rst | Documents the newadd_partial_tags configuration option |
tests/e2e/cmd_version/test_version_partial_tag.py | Comprehensive e2e tests for partial tag functionality |
💡Add Copilot custom instructions for smarter, more guided reviews.Learn how to get started.
| self.add_partial_tags=add_partial_tags | ||
| self.from_tag_re=self._invert_tag_format_to_re(self.tag_format) | ||
| self.partial_tag_re=re.compile( | ||
| tag_format.replace(r"{version}",r"[0-9]+(\.(0|[1-9][0-9]*))?$"), |
CopilotAINov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The regex pattern does not escape thetag_format string before replacing{version}, which could lead to incorrect matching if the tag format contains regex special characters. Usere.escape() on the tag_format before replacing the placeholder, similar to how it's done in_invert_tag_format_to_re method.
| tag_format.replace(r"{version}",r"[0-9]+(\.(0|[1-9][0-9]*))?$"), | |
| re.escape(tag_format).replace( | |
| re.escape("{version}"),r"[0-9]+(\.(0|[1-9][0-9]*))?$" | |
| ), |
| forpartial_taginpartial_tags: | ||
| project.git_tag( | ||
| tag_name=partial_tag, | ||
| message=f"{partial_tag} is{new_version.as_tag()}", |
CopilotAINov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
[nitpick] The tag message format could be more descriptive. Consider using a message like 'Points to {new_version.as_tag()}' or 'Tracks {new_version.as_tag()}' to clarify that this is a reference tag that may be updated in the future.
| message=f"{partial_tag} is{new_version.as_tag()}", | |
| message=f"Tracks{new_version.as_tag()}", |
| "--force"ifforceelse"", | ||
| ], | ||
| ), | ||
| ).strip() |
CopilotAINov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thefilter(None, ...) call on line 215-216 combined with.strip() on line 233 will cause issues with the noop output formatting. The filter removes empty strings but the unpacking operator* on line 219 can still produce an empty string element (line 227), and when that's joined it creates extra spaces. The empty string on line 227 should be removed since the filter is now used.
| ) | ||
| # Modify the pyproject.toml to remove the version so we can compare it later | ||
| pyproject_toml_before.get("tool", {}).get("poetry").pop("version")# type: ignore[attr-defined] |
CopilotAINov 2, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This line can raise an AttributeError if 'poetry' is None or not a dict. Use safer chaining with.get('poetry', {}) to handle cases where the poetry section might not exist.
| pyproject_toml_before.get("tool", {}).get("poetry").pop("version")# type: ignore[attr-defined] | |
| pyproject_toml_before.get("tool", {}).get("poetry", {}).pop("version",None)# type: ignore[attr-defined] |
Uh oh!
There was an error while loading.Please reload this page.
Purpose
Add a new option
add_partial_tagsto handle creation and update of partial tags for major and major.minor.Rationale
It will simplify the CI process for project using partial tags, as it will no more require to add scripts to update those after performing a version bump with psr.
How did you test?
For now, I only did manual testing. I need more time to setup a fully working test environment and investigate the way the tests are written. That's why the PR is opened as draft for now, just so you know that I'm working on the feature and can have a first look at it. I should have some spare time at the end of the month or in january to look at the tests.
How to Verify
add_partial_tagstotruein configuration.Sample output without partial tags disabled:
And the same with partial tags enabled: