mafw.devtools.git
Git operations for MAFw development tools.
This module centralizes all functions that shell out to git commands,
used by the release workflow, documentation builder, and dependency management.
Module Attributes
Path to the TOML file containing the project dependencies. |
|
Regular expression used to identify stable git tags in the form |
Functions
Ensure the release process is executed from the |
|
|
Commit tracked release artifacts for the target version. |
|
Commit the unfreezing of dependency upper bounds to |
|
Create the local git tag for the target version. |
Ensure the git working tree is clean (excluding untracked files). |
|
Get the name of the currently checked out branch. |
|
|
Return list of (Version, tag) tuples sorted ascending. |
Return the latest stable tag matching |
|
|
Get the git revision hash for a given reference. |
|
Return True if commit a is ancestor of commit b (git merge-base --is-ancestor). |
|
Ensure the target release tag does not already exist. |
|
Push commits and tags to the remote repository. |
|
Sort tags using semantic versioning comparison. |
- mafw.devtools.git.check_main_branch() None[source]
Ensure the release process is executed from the
mainbranch.- Raises:
DevtoolsError – If the current branch is not
main.
- mafw.devtools.git.commit_changes(version: str, dry_run: bool, *, include_changelog: bool = True) None[source]
Commit tracked release artifacts for the target version.
- Parameters:
version (str) – Target release version.
dry_run (bool) – Whether command execution is disabled.
include_changelog (bool) – Whether
CHANGELOG.mdshould be staged and committed as part of the release artifacts.
- mafw.devtools.git.commit_dependency_unfreeze(dry_run: bool) None[source]
Commit the unfreezing of dependency upper bounds to
main.- Parameters:
dry_run (bool) – Whether command execution is disabled.
- mafw.devtools.git.create_tag(version: str, dry_run: bool) str[source]
Create the local git tag for the target version.
- Parameters:
version (str) – Target release version.
dry_run (bool) – Whether command execution is disabled.
- Returns:
Created tag name.
- Return type:
str
- mafw.devtools.git.ensure_clean_git() None[source]
Ensure the git working tree is clean (excluding untracked files).
- Raises:
DevtoolsError – If tracked changes are present.
- mafw.devtools.git.get_current_branch() str[source]
Get the name of the currently checked out branch.
- Returns:
Name of the current branch
- Return type:
str
- mafw.devtools.git.get_git_tags(min_version: str | None = None) list[tuple[Version, Any]][source]
Return list of (Version, tag) tuples sorted ascending.
- Parameters:
min_version (str | None) – Minimum version to consider, defaults to None
- Returns:
List of (Version, tag) tuples
- Return type:
list[tuple[Version, Any]]
- mafw.devtools.git.get_last_stable_tag() str | None[source]
Return the latest stable tag matching
vX.Y.Z.- Returns:
Latest stable tag or
Nonewhen no stable tags are present.- Return type:
str | None
- mafw.devtools.git.git_rev_of(ref: str) str[source]
Get the git revision hash for a given reference.
- Parameters:
ref (str) – Git reference (tag, branch, commit hash)
- Returns:
Git revision hash
- Return type:
str
- Raises:
RuntimeError – If git rev-list fails
- mafw.devtools.git.is_ancestor(a: str, b: str) bool[source]
Return True if commit a is ancestor of commit b (git merge-base –is-ancestor).
- Parameters:
a (str) – First commit reference
b (str) – Second commit reference
- Returns:
True if a is ancestor of b
- Return type:
bool
- mafw.devtools.git.prevent_duplicate_tag(version: str) None[source]
Ensure the target release tag does not already exist.
- Parameters:
version (str) – Target release version.
- Raises:
DevtoolsError – If
v<version>already exists.
- mafw.devtools.git.push_changes(dry_run: bool) None[source]
Push commits and tags to the remote repository.
- Parameters:
dry_run (bool) – Whether command execution is disabled.
- mafw.devtools.git.sort_tags_semver(tags: list[str]) list[str][source]
Sort tags using semantic versioning comparison.
- Parameters:
tags (list[str]) – List of tag strings to sort
- Returns:
Sorted list of tag strings
- Return type:
list[str]
- mafw.devtools.git.PYPROJECT_FILE = PosixPath('pyproject.toml')
Path to the TOML file containing the project dependencies.
- mafw.devtools.git.STABLE_TAG_PATTERN = re.compile('^v(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<micro>\\d+)$')
Regular expression used to identify stable git tags in the form
vX.Y.Z.