Skip to content

Commit 6b0c5b1

Browse files
authored
🐛 fix prerelease shortcut tags (#64)
<!-- Copyright (C) 2020-2022 Arm Limited or its affiliates and Contributors. All rights reserved. SPDX-License-Identifier: Apache-2.0 --> ### Description fix prerelease shortcut tags ### Test Coverage <!-- Please put an `x` in the correct box e.g. `[x]` to indicate the testing coverage of this change. --> - [x] This change is covered by existing or additional automated tests. - [ ] Manual testing has been performed (and evidence provided) as automated testing was not feasible. - [ ] Additional tests are not required for this change (e.g. documentation update).
1 parent e510d43 commit 6b0c5b1

File tree

4 files changed

+25
-11
lines changed

4 files changed

+25
-11
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# No Op plugin
22

3-
This plugin is used for simple git projects when `PROGRAMMING_LANGUAGE` is set to `noop`.
3+
This plugin is used when `PROGRAMMING_LANGUAGE` is set to `noop`.
44

55
## Release
6-
Only git operations (tagging, version incrementation, changelog commit) are performed
6+
This plugin performs no operation
77

88
## Documentation
99
N/A

continuous_delivery_scripts/utils/versioning.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,24 @@ def determine_version_shortcuts(
108108
if not tag_shortcut:
109109
return shortcuts
110110
major_version = version_elements.get(auto_version_tool.definitions.SemVerSigFig.major, None)
111-
if major_version or major_version == 0:
112-
shortcuts[f"{major_version}"] = True
113111
minor_version = version_elements.get(auto_version_tool.definitions.SemVerSigFig.minor, None)
114-
if (minor_version or minor_version == 0) and (major_version or major_version == 0):
115-
shortcuts[f"{major_version}.{minor_version}"] = True
116-
if commit_type == CommitType.BETA:
112+
if commit_type == CommitType.RELEASE:
113+
if major_version or major_version == 0:
114+
shortcuts[f"{major_version}"] = True
115+
if (minor_version or minor_version == 0) and (major_version or major_version == 0):
116+
shortcuts[f"{major_version}.{minor_version}"] = True
117+
elif commit_type == CommitType.BETA:
117118
shortcuts[str(auto_version_tool.config.PRERELEASE_TOKEN)] = False
118-
if commit_type == CommitType.DEVELOPMENT:
119+
if major_version or major_version == 0:
120+
shortcuts[f"{major_version}-{auto_version_tool.config.PRERELEASE_TOKEN}"] = True
121+
if (minor_version or minor_version == 0) and (major_version or major_version == 0):
122+
shortcuts[f"{major_version}.{minor_version}-{auto_version_tool.config.PRERELEASE_TOKEN}"] = True
123+
elif commit_type == CommitType.DEVELOPMENT:
119124
shortcuts[str(auto_version_tool.config.BUILD_TOKEN)] = False
125+
if major_version or major_version == 0:
126+
shortcuts[f"{major_version}-{auto_version_tool.config.BUILD_TOKEN}"] = True
127+
if (minor_version or minor_version == 0) and (major_version or major_version == 0):
128+
shortcuts[f"{major_version}.{minor_version}-{auto_version_tool.config.BUILD_TOKEN}"] = True
120129
commit_count = version_elements.get(auto_version_tool.Constants.COMMIT_COUNT_FIELD, None)
121130
if not commit_count:
122131
with LocalProjectRepository() as git:

news/20221222112207.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:bug: prerelease tag shortcuts

tests/versioning/test_versioning.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,17 @@ def test_determine_version_shortcuts(self):
8181
{}, determine_version_shortcuts(CommitType.RELEASE, False, True, {definitions.SemVerSigFig.minor: "1"})
8282
)
8383
self.assertDictEqual(
84-
{"1": True, "1.1": True, config.PRERELEASE_TOKEN: False},
84+
{
85+
config.PRERELEASE_TOKEN: False,
86+
f"1-{config.PRERELEASE_TOKEN}": True,
87+
f"1.1-{config.PRERELEASE_TOKEN}": True,
88+
},
8589
determine_version_shortcuts(
8690
CommitType.BETA, True, True, {definitions.SemVerSigFig.major: "1", definitions.SemVerSigFig.minor: "1"}
8791
),
8892
)
8993
self.assertTrue(
90-
"1.1"
94+
f"1.1-{config.BUILD_TOKEN}"
9195
in determine_version_shortcuts(
9296
CommitType.DEVELOPMENT,
9397
True,
@@ -96,7 +100,7 @@ def test_determine_version_shortcuts(self):
96100
).keys()
97101
)
98102
self.assertTrue(
99-
"1"
103+
f"1-{config.BUILD_TOKEN}"
100104
in determine_version_shortcuts(
101105
CommitType.DEVELOPMENT,
102106
True,

0 commit comments

Comments
 (0)