fix: CalVer not working correctly with zero-padded formats (fixes #320)#321
Open
oharo3109 wants to merge 1 commit intoSongmu:mainfrom
Open
fix: CalVer not working correctly with zero-padded formats (fixes #320)#321oharo3109 wants to merge 1 commit intoSongmu:mainfrom
oharo3109 wants to merge 1 commit intoSongmu:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Calendar Versioning (CalVer) behavior so zero-padded versions (e.g., 2026.0302.0) are preserved when rendering/tagging versions, and attempts to ensure version files are bumped appropriately in CalVer mode.
Changes:
- Update
(*semv).Naked()to preserve the original CalVer string (including zero-padding) when a parsedcalver.Calverinstance isn’t available. - In
tagpr.Run, add a CalVer-specific path intended to bump configured version files after reloading config (post cherry-pick). - Add tests covering cross-date CalVer bumping and zero-padding preservation for
Naked()/Tag().
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tagpr.go | Adds CalVer-specific version-file bumping behavior after config reload in Run(). |
| semver.go | Adjusts Naked() to preserve original CalVer formatting (zero-padding) when cv is nil. |
| calver_test.go | Adds regression tests for CalVer cross-date behavior and zero-padding preservation. |
You can also share your feedback on Copilot code review. Take the survey.
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.
Problem
When using CalVer formats with zero-padded components (e.g.,
YYYY.0M0D.MICRO), tagpr wasgenerating PRs with the same version as the current one instead of the expected new CalVer
date-based version.
Example: With format
YYYY.0M0D.MICROand current tagv2026.0227.10, running tagpron March 2nd should produce
v2026.0302.0, but instead it producedv2026.0227.10.Changes
semver.go:Naked()falls back tooriginalVersionwhenasCalendarVersion=trueand
cv==nil, preserving zero-padded components like0M0D.tagpr.go: After cherry-picks, CalVer mode re-appliesbumpVersionFileinstead ofreading from the file to override
nextVer.calver_test.go: Added test cases covering zero-padded formats (YYYY.0M0D.MICRO,YYYY.0M.MICRO) including cross-date scenarios (the exact user-reported bug scenario).