-
-
Notifications
You must be signed in to change notification settings - Fork 312
feat(tags): enable version schemes with less than 3 components #1705
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
Open
YazdanRa
wants to merge
12
commits into
commitizen-tools:master
from
YazdanRa:feature/single-number-version
+150
−1
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
b78e303
build: update dev dependencies
Lee-W 8b1fad6
feat: add custom validation
benediktziegler 8265c90
feat: Drop support for Python 3.9 as EOL reached and add Python 3.14 ...
Lee-W 2072f8e
style: remove Python 3.9 compatible code
Lee-W 6ad0bf1
feat(tags): enable version schemes with less than 3 components
YazdanRa be4ccc3
Merge branch 'v4-11-0' into feature/single-number-version
YazdanRa 956c8fb
Merge branch 'master' into feature/single-number-version
YazdanRa 6d94ba7
feat(tags): add support for finding latest matching tag for incomplet...
YazdanRa 68cf533
Merge branch 'master' into feature/single-number-version
YazdanRa 80950cd
fix: add tests for finding tags with partial versions
YazdanRa f91f2ac
Merge branch 'master' into feature/single-number-version
YazdanRa 0f729c4
fix: update the unit test to comply with recent changes
YazdanRa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| from commitizen.git import GitTag | ||
| from commitizen.tags import TagRules | ||
|
|
||
|
|
||
| def _git_tag(name: str) -> GitTag: | ||
| return GitTag(name, "rev", "2024年01月01日") | ||
|
|
||
|
|
||
| def test_find_tag_for_partial_version_returns_latest_match(): | ||
| tags = [ | ||
| _git_tag("1.2.0"), | ||
| _git_tag("1.2.2"), | ||
| _git_tag("1.2.1"), | ||
| _git_tag("1.3.0"), | ||
| ] | ||
|
|
||
| rules = TagRules() | ||
|
|
||
| found = rules.find_tag_for(tags, "1.2") | ||
|
|
||
| assert found is not None | ||
| assert found.name == "1.2.2" | ||
|
|
||
|
|
||
| def test_find_tag_for_full_version_remains_exact(): | ||
| tags = [ | ||
| _git_tag("1.2.0"), | ||
| _git_tag("1.2.2"), | ||
| _git_tag("1.2.1"), | ||
| ] | ||
|
|
||
| rules = TagRules() | ||
|
|
||
| found = rules.find_tag_for(tags, "1.2.1") | ||
|
|
||
| assert found is not None | ||
| assert found.name == "1.2.1" | ||
|
|
||
|
|
||
| def test_find_tag_for_partial_version_with_prereleases_prefers_latest_version(): | ||
| tags = [ | ||
| _git_tag("1.2.0b1"), | ||
| _git_tag("1.2.0"), | ||
| _git_tag("1.2.1b1"), | ||
| ] | ||
|
|
||
| rules = TagRules() | ||
|
|
||
| found = rules.find_tag_for(tags, "1.2") | ||
|
|
||
| assert found is not None | ||
| # 1.2.1b1 > 1.2.0 so it should be selected | ||
| assert found.name == "1.2.1b1" | ||
|
|
||
|
|
||
| def test_find_tag_for_partial_version_respects_tag_format(): | ||
| tags = [ | ||
| _git_tag("v1.2.0"), | ||
| _git_tag("v1.2.1"), | ||
| _git_tag("v1.3.0"), | ||
| ] | ||
|
|
||
| rules = TagRules(tag_format="v$version") | ||
|
|
||
| found = rules.find_tag_for(tags, "1.2") | ||
|
|
||
| assert found is not None | ||
| assert found.name == "v1.2.1" | ||
|
|
||
| found = rules.find_tag_for(tags, "1") | ||
|
|
||
| assert found is not None | ||
| assert found.name == "v1.3.0" | ||
|
|
||
|
|
||
| def test_find_tag_for_partial_version_returns_none_when_no_match(): | ||
| tags = [ | ||
| _git_tag("2.0.0"), | ||
| _git_tag("2.1.0"), | ||
| ] | ||
|
|
||
| rules = TagRules() | ||
|
|
||
| found = rules.find_tag_for(tags, "1.2") | ||
|
|
||
| assert found is None | ||
|
|
||
|
|
||
| def test_find_tag_for_partial_version_ignores_invalid_tags(): | ||
| tags = [ | ||
| _git_tag("not-a-version"), | ||
| _git_tag("1.2.0"), | ||
| _git_tag("1.2.1"), | ||
| ] | ||
|
|
||
| rules = TagRules() | ||
|
|
||
| found = rules.find_tag_for(tags, "1.2") | ||
|
|
||
| assert found is not None | ||
| assert found.name == "1.2.1" |
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.