@@ -40,7 +40,7 @@ <h1 class="title">Module <code>continuous_delivery_scripts.utils.versioning</cod
40
40
import logging
41
41
import os
42
42
from auto_version import auto_version_tool
43
- from typing import Optional, Tuple, Dict, List
43
+ from typing import Optional, Tuple, Dict
44
44
45
45
from continuous_delivery_scripts.utils.configuration import configuration, ConfigurationVariable
46
46
from continuous_delivery_scripts.utils.definitions import CommitType
@@ -120,23 +120,36 @@ <h1 class="title">Module <code>continuous_delivery_scripts.utils.versioning</cod
120
120
return new_version
121
121
122
122
123
- def determine_version_shortcuts(commit_type: CommitType, version_elements: Dict[str, str]) -> List[str]:
123
+ def determine_version_shortcuts(
124
+ commit_type: CommitType, tag_latest: bool, tag_shortcut: bool, version_elements: Dict[str, str]
125
+ ) -> Dict[str, bool]:
124
126
"""Determine the different version shortcuts i.e. major, major.minor, pre depending on the release type.
125
127
126
128
Args:
127
129
commit_type: commit type
130
+ tag_latest: whether to tag release with `Latest`
131
+ tag_shortcut: whether to set additional shortcuts
128
132
version_elements: version elements
133
+
134
+ Returns:
135
+ dict: A dictionary of shortcuts and a flag specifying
136
+ whether it is a version string or bespoke shortcut such as latest
129
137
"""
130
- shortcuts = []
138
+ shortcuts = {}
139
+ if commit_type == CommitType.RELEASE and tag_latest:
140
+ shortcuts["latest"] = False
141
+ if not tag_shortcut:
142
+ return shortcuts
131
143
major_version = version_elements.get(auto_version_tool.definitions.SemVerSigFig.major, None)
132
144
if major_version:
133
- shortcuts.append( major_version)
145
+ shortcuts[ major_version] = True
134
146
minor_version = version_elements.get(auto_version_tool.definitions.SemVerSigFig.minor, None)
135
147
if minor_version and major_version:
136
- shortcuts.append( f"{major_version}.{minor_version}")
148
+ shortcuts[ f"{major_version}.{minor_version}"] = True
137
149
if commit_type == CommitType.BETA:
138
- shortcuts.append( auto_version_tool.config.PRERELEASE_TOKEN)
150
+ shortcuts[ auto_version_tool.config.PRERELEASE_TOKEN] = False
139
151
if commit_type == CommitType.DEVELOPMENT:
152
+ shortcuts[auto_version_tool.config.BUILD_TOKEN] = False
140
153
commit_count = version_elements.get(auto_version_tool.Constants.COMMIT_COUNT_FIELD, None)
141
154
if not commit_count:
142
155
with LocalProjectRepository() as git:
@@ -145,7 +158,7 @@ <h1 class="title">Module <code>continuous_delivery_scripts.utils.versioning</cod
145
158
if not commit_hash:
146
159
with LocalProjectRepository() as git:
147
160
commit_hash = git.get_commit_hash()
148
- shortcuts.append( f"{auto_version_tool.config.BUILD_TOKEN}.{commit_count}+{commit_hash}")
161
+ shortcuts[ f"{auto_version_tool.config.BUILD_TOKEN}.{commit_count}+{commit_hash}"] = False
149
162
150
163
return shortcuts
151
164
@@ -234,38 +247,61 @@ <h2 id="returns">Returns</h2>
234
247
</ details >
235
248
</ dd >
236
249
< dt id ="continuous_delivery_scripts.utils.versioning.determine_version_shortcuts "> < code class ="name flex ">
237
- < span > def < span class ="ident "> determine_version_shortcuts</ span > </ span > (< span > commit_type: < a title ="continuous_delivery_scripts.utils.definitions.CommitType " href ="definitions.html#continuous_delivery_scripts.utils.definitions.CommitType "> CommitType</ a > , version_elements: Dict[str, str]) ‑> List [str]</ span >
250
+ < span > def < span class ="ident "> determine_version_shortcuts</ span > </ span > (< span > commit_type: < a title ="continuous_delivery_scripts.utils.definitions.CommitType " href ="definitions.html#continuous_delivery_scripts.utils.definitions.CommitType "> CommitType</ a > , tag_latest: bool, tag_shortcut: bool, version_elements: Dict[str, str]) ‑> Dict [str, bool ]</ span >
238
251
</ code > </ dt >
239
252
< dd >
240
253
< div class ="desc "> < p > Determine the different version shortcuts i.e. major, major.minor, pre depending on the release type.</ p >
241
254
< h2 id ="args "> Args</ h2 >
242
255
< dl >
243
256
< dt > < strong > < code > commit_type</ code > </ strong > </ dt >
244
257
< dd > commit type</ dd >
258
+ < dt > < strong > < code > tag_latest</ code > </ strong > </ dt >
259
+ < dd > whether to tag release with < code > Latest</ code > </ dd >
260
+ < dt > < strong > < code > tag_shortcut</ code > </ strong > </ dt >
261
+ < dd > whether to set additional shortcuts</ dd >
245
262
< dt > < strong > < code > version_elements</ code > </ strong > </ dt >
246
263
< dd > version elements</ dd >
247
- </ dl > </ div >
264
+ </ dl >
265
+ < h2 id ="returns "> Returns</ h2 >
266
+ < dl >
267
+ < dt > < code > dict</ code > </ dt >
268
+ < dd > A dictionary of shortcuts and a flag specifying</ dd >
269
+ </ dl >
270
+ < p > whether it is a version string or bespoke shortcut such as latest</ p > </ div >
248
271
< details class ="source ">
249
272
< summary >
250
273
< span > Expand source code</ span >
251
274
</ summary >
252
- < pre > < code class ="python "> def determine_version_shortcuts(commit_type: CommitType, version_elements: Dict[str, str]) -> List[str]:
275
+ < pre > < code class ="python "> def determine_version_shortcuts(
276
+ commit_type: CommitType, tag_latest: bool, tag_shortcut: bool, version_elements: Dict[str, str]
277
+ ) -> Dict[str, bool]:
253
278
"""Determine the different version shortcuts i.e. major, major.minor, pre depending on the release type.
254
279
255
280
Args:
256
281
commit_type: commit type
282
+ tag_latest: whether to tag release with `Latest`
283
+ tag_shortcut: whether to set additional shortcuts
257
284
version_elements: version elements
285
+
286
+ Returns:
287
+ dict: A dictionary of shortcuts and a flag specifying
288
+ whether it is a version string or bespoke shortcut such as latest
258
289
"""
259
- shortcuts = []
290
+ shortcuts = {}
291
+ if commit_type == CommitType.RELEASE and tag_latest:
292
+ shortcuts["latest"] = False
293
+ if not tag_shortcut:
294
+ return shortcuts
260
295
major_version = version_elements.get(auto_version_tool.definitions.SemVerSigFig.major, None)
261
296
if major_version:
262
- shortcuts.append( major_version)
297
+ shortcuts[ major_version] = True
263
298
minor_version = version_elements.get(auto_version_tool.definitions.SemVerSigFig.minor, None)
264
299
if minor_version and major_version:
265
- shortcuts.append( f"{major_version}.{minor_version}")
300
+ shortcuts[ f"{major_version}.{minor_version}"] = True
266
301
if commit_type == CommitType.BETA:
267
- shortcuts.append( auto_version_tool.config.PRERELEASE_TOKEN)
302
+ shortcuts[ auto_version_tool.config.PRERELEASE_TOKEN] = False
268
303
if commit_type == CommitType.DEVELOPMENT:
304
+ shortcuts[auto_version_tool.config.BUILD_TOKEN] = False
269
305
commit_count = version_elements.get(auto_version_tool.Constants.COMMIT_COUNT_FIELD, None)
270
306
if not commit_count:
271
307
with LocalProjectRepository() as git:
@@ -274,7 +310,7 @@ <h2 id="args">Args</h2>
274
310
if not commit_hash:
275
311
with LocalProjectRepository() as git:
276
312
commit_hash = git.get_commit_hash()
277
- shortcuts.append( f"{auto_version_tool.config.BUILD_TOKEN}.{commit_count}+{commit_hash}")
313
+ shortcuts[ f"{auto_version_tool.config.BUILD_TOKEN}.{commit_count}+{commit_hash}"] = False
278
314
279
315
return shortcuts</ code > </ pre >
280
316
</ details >
0 commit comments