Semver
semver
Semantic versioning — parse commits and compute next version.
VersionBump
dataclass
Result of a semver computation.
Attributes:
| Name | Type | Description |
|---|---|---|
current |
str
|
Current tag (e.g. |
next |
str
|
Next tag (e.g. |
bump |
str
|
Bump type ( |
commits |
list[str]
|
One-line commit summaries since last tag. |
breaking |
bool
|
Whether a breaking change was detected. |
Source code in packages/axm-git/src/axm_git/core/semver.py
classify_commit(subject)
Classify a single conventional-commit subject.
Reuses the module regexes so per-commit labelling stays consistent
with :func:compute_bump. Internal-public: importable by sibling
tools (e.g. release_diff) but intentionally absent from __all__.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
subject
|
str
|
A commit subject line, optionally prefixed by a short
hash ( |
required |
Returns:
| Type | Description |
|---|---|
str
|
|
bool
|
( |
tuple[str, bool]
|
|
tuple[str, bool]
|
when the subject carries a conventional prefix, falling back to |
tuple[str, bool]
|
|
tuple[str, bool]
|
commits or |
tuple[str, bool]
|
logic (:func: |
Source code in packages/axm-git/src/axm_git/core/semver.py
compute_bump(commits, current_tag)
Compute the next semver version from commit messages.
Rules (pre-1.0, i.e. major == 0):
- feat!: or BREAKING CHANGE: → minor bump
- feat: → minor bump
- everything else → patch bump
Rules (post-1.0):
- feat!: or BREAKING CHANGE: → major bump
- feat: → minor bump
- everything else → patch bump
Accepts both git log --oneline lines (<short-hash> <message>)
and raw conventional-commit messages (feat: x). The leading token
is stripped only when it matches a short-hash shape
(hex, 3-40 chars); otherwise the whole line is treated as the message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
commits
|
list[str]
|
Commit lines, either oneline ( |
required |
current_tag
|
str
|
Current version tag (e.g. |
required |
Returns:
| Type | Description |
|---|---|
VersionBump
|
VersionBump with computed next version. |
Source code in packages/axm-git/src/axm_git/core/semver.py
parse_tag(tag)
Parse a semver tag string into (major, minor, patch).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
Version string, with or without |
required |
Returns:
| Type | Description |
|---|---|
tuple[int, int, int]
|
Tuple of (major, minor, patch). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the tag doesn't match semver format. |