Skip to content

Commit 173be1a

Browse files
committed
Adds branch_name to SCM information
1 parent 9d965e5 commit 173be1a

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

bumpversion/scm.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class SCMInfo:
2424
commit_sha: Optional[str] = None
2525
distance_to_latest_tag: Optional[int] = None
2626
current_version: Optional[str] = None
27+
branch_name: Optional[str] = None
2728
dirty: Optional[bool] = None
2829

2930
def __str__(self):
@@ -240,11 +241,15 @@ def latest_tag_info(cls, tag_pattern: str) -> SCMInfo:
240241
]
241242
result = subprocess.run(git_cmd, text=True, check=True, capture_output=True) # noqa: S603
242243
describe_out = result.stdout.strip().split("-")
244+
245+
git_cmd = ["git", "rev-parse", "--abbrev-ref", "HEAD"]
246+
result = subprocess.run(git_cmd, text=True, check=True, capture_output=True) # noqa: S603
247+
branch_name = result.stdout.strip()
243248
except subprocess.CalledProcessError as e:
244249
logger.debug("Error when running git describe: %s", e.stderr)
245250
return SCMInfo(tool=cls)
246251

247-
info = SCMInfo(tool=cls)
252+
info = SCMInfo(tool=cls, branch_name=branch_name)
248253

249254
if describe_out[-1].strip() == "dirty":
250255
info.dirty = True

docsrc/configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ In this example (in TOML):
262262
serialize = [
263263
"{major}.{minor}.{patch}",
264264
"{major}.{minor}",
265-
"{major}"
265+
"{major}"
266266
]
267267
```
268268

docsrc/search-and-replace.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ You can use bump-my-version to maintain the major version number within the `go.
110110

111111
```toml
112112
[tool.bumpversion]
113-
current_version = 2.21.4
113+
current_version = "2.21.4"
114114
115115
[[tool.bumpversion.files]]
116116
filename = "go.mod"

0 commit comments

Comments
 (0)