Skip to content

Commit 0cbdcb1

Browse files
committed
making sure the count is always available
1 parent d79a88f commit 0cbdcb1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

continuous_delivery_scripts/generate_news.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import subprocess
1212
from auto_version import auto_version_tool
1313
from continuous_delivery_scripts.utils.definitions import CommitType
14+
from continuous_delivery_scripts.utils.git_helpers import LocalProjectRepository
1415
from continuous_delivery_scripts.utils.configuration import configuration, ConfigurationVariable
1516
from continuous_delivery_scripts.utils.logging import log_exception, set_log_level
1617
from continuous_delivery_scripts.utils.filesystem_helpers import cd
@@ -85,13 +86,17 @@ def _update_version_string(
8586
version_elements: version elements
8687
"""
8788
if commit_type == CommitType.DEVELOPMENT:
89+
commit_count = version_elements.get(auto_version_tool.Constants.COMMIT_COUNT_FIELD)
90+
if not commit_count:
91+
with LocalProjectRepository() as git:
92+
commit_count = git.get_commit_count()
8893
return "%s-%s.%s+%s" % (
8994
new_version,
9095
auto_version_tool.config.BUILD_TOKEN,
91-
version_elements.get(auto_version_tool.Constants.COMMIT_COUNT_FIELD),
96+
commit_count,
9297
version_elements.get(auto_version_tool.Constants.COMMIT_FIELD),
9398
)
94-
return new_version
99+
return new_version
95100

96101

97102
def _get_version_elements(native_version_elements: Dict[str, str]) -> Dict[str, str]:

0 commit comments

Comments
 (0)