repomatic.mailmap moduleΒΆ

Group the contributor identities of the git history into a .mailmap.

Backs the sync-mailmap command: parses the existing mappings as the reference for identities already grouped, reads every author and committer the history holds, and appends whatever is not covered yet.

repomatic.mailmap.MAILMAP_PATH = PosixPath('.mailmap')ΒΆ

Canonical path to the .mailmap file in the repository root.

class repomatic.mailmap.Record(canonical='', aliases=set(), pre_comment='')[source]ΒΆ

Bases: object

A mailmap identity mapping entry.

canonical: str = ''ΒΆ

The identity every alias maps to, in Name <email> form.

aliases: set[str]ΒΆ

The other identities of the same contributor.

pre_comment: str = ''ΒΆ

The comment and blank lines written above the mapping.

property identities: frozenset[str]ΒΆ

Every identity of the record, lowercased.

Identity matching is case insensitive, per the mailmap syntax.

property mapping: strΒΆ

The mapping line: the canonical identity, then the sorted aliases.

The aliases sort without case sensitivity. The canonical identity keeps its place in front.

class repomatic.mailmap.Mailmap[source]ΒΆ

Bases: object

Helpers to manipulate .mailmap files.

.mailmap file format is documented on Git website.

Initialize the mailmap with an empty list of records.

records: list[Record]ΒΆ
static split_identities(mapping)[source]ΒΆ

Split a mapping of identities and normalize them.

Return type:

tuple[str, set[str]]

parse(content)[source]ΒΆ

Parse mailmap content and add it to the current list of records.

Each non-empty, non-comment line is considered a mapping entry.

The preceding lines of a mapping entry are kept attached to it as pre-comments, so the layout will be preserved on rendering, during which records are sorted.

Return type:

None

update_from_git()[source]ΒΆ

Add to internal records all missing contributors found in commit history.

No normalization happens: all variations of authors and committers strings attached to all commits are considered. A contributor already registered, as a canonical identity or as an alias, is not added again.

Raises:

RuntimeError – When git fails, carrying its stderr.

Return type:

None

render()[source]ΒΆ

Render internal records in Mailmap format.

The records sort by canonical identity, without case sensitivity. The pre-comment of the first parsed record is the comment that opens the file, so it stays at the top, whichever record sorts first.

Return type:

str