Skip to main content

gixo

gixo validates Git branch names and commit messages against configurable rules.

Usage

Branch names

from gixo import validate_branch

result = validate_branch(
    "feature/PROJ-123-add-login",
    pattern=r"^(feature|bugfix)/[A-Z]+-\d+-.+$",
)

if not result.is_valid:
    print(result.message)

validate_branch takes the branch name as an argument; it never runs Git itself. It returns a ValidationResult:

  • is_valid is True when no rules failed.
  • message is "OK", or a human-readable explanation of what failed.
  • violations is a tuple of Violation(rule, message) with a stable rule id:
Rule Fails when
branch.empty The name is empty or only whitespace.
branch.whitespace The name contains any whitespace. Names are not trimmed.
branch.pattern The name does not match pattern.

Behavior:

  • The whole name must match the pattern (re.fullmatch), so ^ and $ anchors are optional.
  • Checks stop at the first failure, in the order listed above.
  • An invalid regex raises gixo.ConfigurationError, even when the name is empty, so configuration mistakes are never reported as validation failures.

Commit messages

from gixo import validate_commit_message

result = validate_commit_message(
    "feat(api): add login endpoint",
    allowed_types=["feat", "fix", "docs"],
    max_subject_length=72,
    require_ticket=False,
)

for violation in result.violations:
    print(f"[{violation.rule}] {violation.message}")

Messages follow Conventional Commits: the first line (the subject) is type(scope)!: description, where the scope and ! are optional.

Setting Default Meaning
convention "conventional" The only supported convention so far.
allowed_types feat, fix, docs, refactor, test, build, chore Accepted types. Case-sensitive.
max_subject_length 72 Maximum length of the subject line.
require_ticket False Require a ticket id somewhere in the message.
ticket_pattern [A-Z][A-Z0-9]+-\d+ Regex for a ticket id, e.g. PROJ-123.
allow_merge_commits True Accept Merge ... subjects without other checks.
allow_revert_commits True Accept Revert "..." subjects without other checks.
Rule Fails when
commit.empty The message is empty or only whitespace. No other rules run.
commit.whitespace The subject starts with whitespace.
commit.format The subject is not type(scope)!: description.
commit.type The type is not in allowed_types.
commit.subject_length The subject is longer than max_subject_length.
commit.body_separator A body follows the subject without a blank line between them.
commit.ticket require_ticket is on and ticket_pattern appears nowhere in the message.

Behavior:

  • Every failing rule is reported, not just the first. When the subject starts with whitespace, commit.format and commit.type are skipped.
  • Subject length counts the whole first line, including the type(scope): prefix, matching what git log --oneline shows.
  • Trailing whitespace and newlines are ignored; leading whitespace is rejected.
  • The ticket may appear in the subject, body, or a footer such as Refs: PROJ-123.
  • Merge and revert commits, when allowed, skip all rules, including the ticket rule. Release commits have no special case; write them as chore(release): v1.2.0.
  • Git comment lines (# ...) are not stripped; pass the final message text.
  • Invalid settings raise gixo.ConfigurationError before the message is checked.

Development

Requires Python 3.11 or newer.

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -e ".[dev]"
pytest
ruff check .
ruff format --check .
mypy src

Metadata

Release files for gixo 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gixo 0.1.0
File Size Uploaded
gixo-0.1.0.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gixo 0.1.0
File Interpreter ABI Platform
gixo-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.4 kB

Release files / gixo-0.1.0.tar.gz

Download URL gixo-0.1.0.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c83af6e9942e4918bf89788643f315d55e92712b3a65fb90049208c2bbb54f46
BLAKE2b-256 checksum
How to use checksums
da0050c08671b909c99f9194eadbefb1378f9e54e8cf0116de9bdea561d9ad02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Release files / gixo-0.1.0-py3-none-any.whl

Download URL gixo-0.1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0f4a0fc779597f31138f8e15da6ea1520ab34f79108be526d776d84a9dafe9cc
BLAKE2b-256 checksum
How to use checksums
bd8f988c6a9f268194b58e11b40be9960ce1530938b32375aac64bc204c2d350
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.0

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page