Skip to content

Add .mailmap Validation with mailmap-checker #148329

Description

@cansarigol

Feature or enhancement

Proposal:

Proposal: Add .mailmap Validation with mailmap-checker

Summary

Add automated .mailmap validation to CPython's patchcheck.py and pre-commit configuration using the mailmap-checker tool, ensuring proper formatting, completeness, and preventing duplicate entries.

Background

The .mailmap file was introduced in PR #103696 to map contributor name/email changes in git history. As noted by @zware in that discussion:

"Since we've now started down this road, there may be other contributors who would like to be similarly added here..."

Currently, there's no automated validation, which can lead to:

  • Syntax errors going undetected
  • Unmapped contributor identities across email changes
  • Duplicate or conflicting entries
  • Manual maintenance burden

Proposed Solution

Use the existing mailmap-checker tool (https://github.com/cansarigol/mailmap-checker) which:

  • Detects unmapped Git identities by scanning commit history
  • Groups authors by email and local-part
  • Validates .mailmap syntax and completeness
  • Can auto-fix and suggest entries

Implementation

1. Add to Tools/scripts/patchcheck.py:

def mailmap_checked():
    """Check if .mailmap is properly maintained."""
    try:
        subprocess.check_call(
            ['mailmap-checker', 'check'],
            cwd=SRCDIR,
            stdout=subprocess.DEVNULL,
            stderr=subprocess.DEVNULL
        )
        return True
    except subprocess.CalledProcessError:
        print("Mailmap check failed. Run 'mailmap-checker check' to see details.")
        return False
    except (FileNotFoundError, OSError):
        print("mailmap-checker not installed, skipping mailmap check.")
        return True

2. Add to .pre-commit-config.yaml:

  - repo: https://github.com/cansarigol/mailmap-checker
    rev: v1.0.0  # Use latest stable version
    hooks:
      - id: mailmap-check

3. Update documentation:

Add to Doc/developers/patchcheck.rst or contributing guide:

Mailmap Validation
------------------

CPython uses `.mailmap` to consolidate contributor identities. To validate:

.. code-block:: bash

   # Check for unmapped identities
   mailmap-checker check

   # Auto-fix (preview first)
   mailmap-checker fix --dry-run
   mailmap-checker fix

Related

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pendingThe issue will be closed if no feedback is providedtype-featureA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions