Skip to content

Commit cmd

commit_cmd

build_commit_cmd(message, body, *, skip_hooks=True, author=None)

Build the git commit argument list.

Parameters:

Name Type Description Default
message str

Commit summary line.

required
body str | None

Optional extended commit body.

required
skip_hooks bool

Append --no-verify when True.

True
author str | None

Git --author value ("Name <email>"). When None, git uses the default identity.

None
Source code in packages/axm-git/src/axm_git/core/commit_cmd.py
Python
def build_commit_cmd(
    message: str,
    body: str | None,
    *,
    skip_hooks: bool = True,
    author: str | None = None,
) -> list[str]:
    """Build the ``git commit`` argument list.

    Args:
        message: Commit summary line.
        body: Optional extended commit body.
        skip_hooks: Append ``--no-verify`` when *True*.
        author: Git ``--author`` value (``"Name <email>"``).
            When *None*, git uses the default identity.
    """
    cmd = ["commit", "-m", message]
    if body:
        cmd.extend(["-m", body])
    if skip_hooks:
        cmd.append("--no-verify")
    if author:
        cmd.append(f"--author={author}")
    return cmd