File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -35,3 +35,67 @@ def test_find_tag_for_full_version_remains_exact():
3535
3636 assert found is not None
3737 assert found .name == "1.2.1"
38+
39+
40+ def test_find_tag_for_partial_version_with_prereleases_prefers_latest_version ():
41+ tags = [
42+ _git_tag ("1.2.0b1" ),
43+ _git_tag ("1.2.0" ),
44+ _git_tag ("1.2.1b1" ),
45+ ]
46+
47+ rules = TagRules ()
48+
49+ found = rules .find_tag_for (tags , "1.2" )
50+
51+ assert found is not None
52+ # 1.2.1b1 > 1.2.0 so it should be selected
53+ assert found .name == "1.2.1b1"
54+
55+
56+ def test_find_tag_for_partial_version_respects_tag_format ():
57+ tags = [
58+ _git_tag ("v1.2.0" ),
59+ _git_tag ("v1.2.1" ),
60+ _git_tag ("v1.3.0" ),
61+ ]
62+
63+ rules = TagRules (tag_format = "v$version" )
64+
65+ found = rules .find_tag_for (tags , "1.2" )
66+
67+ assert found is not None
68+ assert found .name == "v1.2.1"
69+
70+ found = rules .find_tag_for (tags , "1" )
71+
72+ assert found is not None
73+ assert found .name == "v1.3.0"
74+
75+
76+ def test_find_tag_for_partial_version_returns_none_when_no_match ():
77+ tags = [
78+ _git_tag ("2.0.0" ),
79+ _git_tag ("2.1.0" ),
80+ ]
81+
82+ rules = TagRules ()
83+
84+ found = rules .find_tag_for (tags , "1.2" )
85+
86+ assert found is None
87+
88+
89+ def test_find_tag_for_partial_version_ignores_invalid_tags ():
90+ tags = [
91+ _git_tag ("not-a-version" ),
92+ _git_tag ("1.2.0" ),
93+ _git_tag ("1.2.1" ),
94+ ]
95+
96+ rules = TagRules ()
97+
98+ found = rules .find_tag_for (tags , "1.2" )
99+
100+ assert found is not None
101+ assert found .name == "1.2.1"
You can’t perform that action at this time.
0 commit comments