Skip to content

Commit 304c599

Browse files
committed
Add current_tag field to scm_info
Updated the scm_info structure to include a new field, current_tag, across various configuration files and source code. This ensures that the current tag is tracked and represented in the output formats correctly.
1 parent 508f87b commit 304c599

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

bumpversion/scm.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class SCMInfo:
2727
commit_sha: Optional[str] = None
2828
distance_to_latest_tag: int = 0
2929
current_version: Optional[str] = None
30+
current_tag: Optional[str] = None
3031
branch_name: Optional[str] = None
3132
short_branch_name: Optional[str] = None
3233
repository_root: Optional[Path] = None
@@ -42,6 +43,7 @@ def __repr__(self):
4243
f"commit_sha={self.commit_sha}, "
4344
f"distance_to_latest_tag={self.distance_to_latest_tag}, "
4445
f"current_version={self.current_version}, "
46+
f"current_tag={self.current_tag}, "
4547
f"branch_name={self.branch_name}, "
4648
f"short_branch_name={self.short_branch_name}, "
4749
f"repository_root={self.repository_root}, "
@@ -286,7 +288,7 @@ def _commit_info(cls, parse_pattern: str, tag_name: str) -> dict:
286288
A dictionary containing information about the latest commit.
287289
"""
288290
tag_pattern = tag_name.replace("{new_version}", "*")
289-
info = dict.fromkeys(["dirty", "commit_sha", "distance_to_latest_tag", "current_version"])
291+
info = dict.fromkeys(["dirty", "commit_sha", "distance_to_latest_tag", "current_version", "current_tag"])
290292
info["distance_to_latest_tag"] = 0
291293
try:
292294
# get info about the latest tag in git
@@ -309,6 +311,7 @@ def _commit_info(cls, parse_pattern: str, tag_name: str) -> dict:
309311

310312
info["commit_sha"] = describe_out.pop().lstrip("g")
311313
info["distance_to_latest_tag"] = int(describe_out.pop())
314+
info["current_tag"] = "-".join(describe_out)
312315
version = cls.get_version_from_tag("-".join(describe_out), tag_name, parse_pattern)
313316
info["current_version"] = version or "-".join(describe_out).lstrip("v")
314317
except subprocess.CalledProcessError as e:

tests/fixtures/basic_cfg_expected.txt

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
'replace': '{new_version}',
8383
'scm_info': {'branch_name': None,
8484
'commit_sha': None,
85+
'current_tag': None,
8586
'current_version': None,
8687
'dirty': None,
8788
'distance_to_latest_tag': 0,

tests/fixtures/basic_cfg_expected.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ replace: "{new_version}"
111111
scm_info:
112112
branch_name: null
113113
commit_sha: null
114+
current_tag: null
114115
current_version: null
115116
dirty: null
116117
distance_to_latest_tag: 0

tests/fixtures/basic_cfg_expected_full.json

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@
126126
"scm_info": {
127127
"branch_name": null,
128128
"commit_sha": null,
129+
"current_tag": null,
129130
"current_version": null,
130131
"dirty": null,
131132
"distance_to_latest_tag": 0,

0 commit comments

Comments
 (0)