Skip to main content

Crate gix_mailmap

Crate gix_mailmap 

Source
Expand description

Parse .mailmap files as used in git repositories and remap names and emails using an accelerated data-structure.

§Examples

use gix_actor::SignatureRef;

let input = b"
Joe R. Developer <joe@example.com> <bugs@example.com>
Jane Doe <jane@example.com> Jane <bugs@example.com>
";

let parsed = gix_mailmap::parse(input)
    .collect::<Result<Vec<_>, _>>()
    .unwrap();
assert_eq!(parsed.len(), 2);

let snapshot = gix_mailmap::Snapshot::new(parsed);
let resolved = snapshot.resolve(
    SignatureRef::from_bytes(b"Jane <bugs@example.com> 1711398853 +0800").unwrap(),
);

assert_eq!(resolved.name, "Jane Doe");
assert_eq!(resolved.email, "jane@example.com");

§Feature Flags

  • serde — Data structures implement serde::Serialize and serde::Deserialize.

Modules§

parse
snapshot

Structs§

Entry
An typical entry of a mailmap, which always contains an old_email by which the mapping is performed to replace the given new_name and new_email.
Snapshot
A data-structure to efficiently store a list of entries for optimal, case-insensitive lookup by email and optionally name to find mappings to new names and/or emails.

Functions§

parse
Parse the given buf of bytes line by line into mapping Entries.
parse_ignore_errors
Similar to parse(), but will skip all lines that didn’t parse correctly, silently squelching all errors.