Skip to main content

Pre-commit hook that checks and maintains .mailmap completeness

Project description

mailmap-checker

PyPI version Python versions CI License: MIT

A pre-commit hook that detects unmapped Git identities by comparing your .mailmap against the full commit history. It groups authors by email address and email local-part so duplicates are caught even across domain changes.

How it works

The checker scans git log for all unique author identities and groups them using two rules:

Rule 1 — Same email (case-insensitive)

Identities that share the exact same email address are the same person.

Alice Johnson <alice@acme.com>
alice.j       <alice@acme.com>   ← same email, grouped together

Rule 2 — Same email local-part (different domain)

Identities whose email local-part (the part before @) matches are likely the same person who changed companies or used a different address.

Alice Johnson <alice.johnson@acme.com>
Alice Johnson <alice.johnson@oldcorp.com>    ← same local-part, grouped
Alice J       <alice.johnson@personal.net>   ← same local-part, grouped

Once groups are built, the checker looks for identities that are not mapped in .mailmap. If a group has more than one identity and any of them is missing from the file, the hook fails and reports the gap.

Example

Given these three identities in git history and an empty .mailmap:

Alice Johnson <alice.johnson@acme.com>
Alice Johnson <alice.johnson@oldcorp.com>
Alice J       <alice.johnson@personal.net>

mailmap-checker check detects the gap:

Found 2 unmapped identities in 1 group:

  Canonical: Alice J <alice.johnson@personal.net>
    - Alice Johnson <alice.johnson@acme.com>
    - Alice Johnson <alice.johnson@oldcorp.com>

mailmap-checker fix --dry-run suggests entries to add:

Suggested .mailmap entries:

  Alice J <alice.johnson@personal.net> Alice Johnson <alice.johnson@acme.com>
  Alice J <alice.johnson@personal.net> Alice Johnson <alice.johnson@oldcorp.com>

Note: When no .mailmap exists, the tool picks the alphabetically first identity as the canonical. In this case it chose Alice J <alice.johnson@personal.net>, but the actual preferred identity is likely Alice Johnson <alice.johnson@acme.com>. The .mailmap format places the canonical (left) and the alias (right) on each line. After running fix, open .mailmap and swap the canonical if needed:

Alice Johnson <alice.johnson@acme.com> Alice Johnson <alice.johnson@oldcorp.com>
Alice Johnson <alice.johnson@acme.com> Alice J <alice.johnson@personal.net>

Installation

Pre-commit hook (recommended)

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/cansarigol/mailmap-checker
    rev: ""  # run: pre-commit autoupdate
    hooks:
      - id: mailmap-check

Then run pre-commit autoupdate to pin the latest release.

Standalone

pip install mailmap-checker

Usage

check

Scan all Git authors and exit non-zero if any identity is missing from .mailmap.

mailmap-checker check

init

Create a .mailmap file (if it does not exist) and run a full check.

mailmap-checker init

fix

Preview or apply suggested .mailmap entries.

# Preview
mailmap-checker fix --dry-run

# Apply
mailmap-checker fix

All commands accept --mailmap <path> to use a custom file path.

Contributing

git clone https://github.com/cansarigol/mailmap-checker.git
cd mailmap-checker
uv sync
uv run poe setup   # installs pre-commit and commit-msg hooks
uv run poe check    # lint + security + tests

Commits must follow Conventional Commits with a required scope (e.g. feat(cli): add --verbose flag).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mailmap_checker-0.1.0.tar.gz (13.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mailmap_checker-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file mailmap_checker-0.1.0.tar.gz.

File metadata

  • Download URL: mailmap_checker-0.1.0.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mailmap_checker-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0eedf6a7e506aaab2c1848934b98589d665f8078ed654639bd1682b1eb4b4bd7
MD5 aa2f52dd98d1d657281a5f9685249bae
BLAKE2b-256 c41000c07f61b8435cbd9d906ee9f1b5bef28714ddc4e91de52b8a026bd805da

See more details on using hashes here.

File details

Details for the file mailmap_checker-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mailmap_checker-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.3 {"installer":{"name":"uv","version":"0.11.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mailmap_checker-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b331ef1d7474e7d2051367da08e96b336a0f3d98c16f0869dfbf17e8036b1fe8
MD5 f08f8ac9be635b6db60e17cd6fb81447
BLAKE2b-256 b9e90b8020ead0e6420c92ec9803fea4b7e59dc945bb603dc4ed3412c2b9e5b0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page