@@ -40,7 +40,7 @@ <h1 class="title">Module <code>continuous_delivery_scripts.utils.versioning</cod
4040import logging
4141import os
4242from auto_version import auto_version_tool
43- from typing import Optional, Tuple, Dict, List
43+ from typing import Optional, Tuple, Dict
4444
4545from continuous_delivery_scripts.utils.configuration import configuration, ConfigurationVariable
4646from continuous_delivery_scripts.utils.definitions import CommitType
@@ -120,23 +120,36 @@ <h1 class="title">Module <code>continuous_delivery_scripts.utils.versioning</cod
120120 return new_version
121121
122122
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]:
124126 """Determine the different version shortcuts i.e. major, major.minor, pre depending on the release type.
125127
126128 Args:
127129 commit_type: commit type
130+ tag_latest: whether to tag release with `Latest`
131+ tag_shortcut: whether to set additional shortcuts
128132 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
129137 """
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
131143 major_version = version_elements.get(auto_version_tool.definitions.SemVerSigFig.major, None)
132144 if major_version:
133- shortcuts.append( major_version)
145+ shortcuts[ major_version] = True
134146 minor_version = version_elements.get(auto_version_tool.definitions.SemVerSigFig.minor, None)
135147 if minor_version and major_version:
136- shortcuts.append( f"{major_version}.{minor_version}")
148+ shortcuts[ f"{major_version}.{minor_version}"] = True
137149 if commit_type == CommitType.BETA:
138- shortcuts.append( auto_version_tool.config.PRERELEASE_TOKEN)
150+ shortcuts[ auto_version_tool.config.PRERELEASE_TOKEN] = False
139151 if commit_type == CommitType.DEVELOPMENT:
152+ shortcuts[auto_version_tool.config.BUILD_TOKEN] = False
140153 commit_count = version_elements.get(auto_version_tool.Constants.COMMIT_COUNT_FIELD, None)
141154 if not commit_count:
142155 with LocalProjectRepository() as git:
@@ -145,7 +158,7 @@ <h1 class="title">Module <code>continuous_delivery_scripts.utils.versioning</cod
145158 if not commit_hash:
146159 with LocalProjectRepository() as git:
147160 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
149162
150163 return shortcuts
151164
@@ -234,38 +247,61 @@ <h2 id="returns">Returns</h2>
234247</ details >
235248</ dd >
236249< 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 >
238251</ code > </ dt >
239252< dd >
240253< div class ="desc "> < p > Determine the different version shortcuts i.e. major, major.minor, pre depending on the release type.</ p >
241254< h2 id ="args "> Args</ h2 >
242255< dl >
243256< dt > < strong > < code > commit_type</ code > </ strong > </ dt >
244257< 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 >
245262< dt > < strong > < code > version_elements</ code > </ strong > </ dt >
246263< 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 >
248271< details class ="source ">
249272< summary >
250273< span > Expand source code</ span >
251274</ 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]:
253278 """Determine the different version shortcuts i.e. major, major.minor, pre depending on the release type.
254279
255280 Args:
256281 commit_type: commit type
282+ tag_latest: whether to tag release with `Latest`
283+ tag_shortcut: whether to set additional shortcuts
257284 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
258289 """
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
260295 major_version = version_elements.get(auto_version_tool.definitions.SemVerSigFig.major, None)
261296 if major_version:
262- shortcuts.append( major_version)
297+ shortcuts[ major_version] = True
263298 minor_version = version_elements.get(auto_version_tool.definitions.SemVerSigFig.minor, None)
264299 if minor_version and major_version:
265- shortcuts.append( f"{major_version}.{minor_version}")
300+ shortcuts[ f"{major_version}.{minor_version}"] = True
266301 if commit_type == CommitType.BETA:
267- shortcuts.append( auto_version_tool.config.PRERELEASE_TOKEN)
302+ shortcuts[ auto_version_tool.config.PRERELEASE_TOKEN] = False
268303 if commit_type == CommitType.DEVELOPMENT:
304+ shortcuts[auto_version_tool.config.BUILD_TOKEN] = False
269305 commit_count = version_elements.get(auto_version_tool.Constants.COMMIT_COUNT_FIELD, None)
270306 if not commit_count:
271307 with LocalProjectRepository() as git:
@@ -274,7 +310,7 @@ <h2 id="args">Args</h2>
274310 if not commit_hash:
275311 with LocalProjectRepository() as git:
276312 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
278314
279315 return shortcuts</ code > </ pre >
280316</ details >
0 commit comments