class Agate::Mailmap

Overview

A mailmap for resolving alternate author/committer names and emails.

# Load from a repository's .mailmap
mm = Mailmap.from_repository(repo)
name, email = mm.resolve("J. Doe", "john@old.com")

# Parse from a string
mm = Mailmap.from_buffer("Proper Name <proper@email.com> <old@email.com>\n")
name, email = mm.resolve("", "old@email.com")
name  # => "Proper Name"
email # => "proper@email.com"

# Resolve a signature
resolved = mm.resolve_signature(commit.author)

Defined in:

agate/mailmap.cr

Constructors

Instance Method Summary

Constructor Detail

def self.from_buffer(content : String) : Mailmap #

Parses a mailmap from a string buffer.


[View source]
def self.from_repository(repo : Repository) : Mailmap #

Loads the mailmap from a repository's configuration (.mailmap file, mailmap.blob, mailmap.file).


[View source]
def self.new : Mailmap #

Creates a new empty mailmap.


[View source]

Instance Method Detail

def add_entry(real_name : String | Nil = nil, real_email : String | Nil = nil, replace_name : String | Nil = nil, replace_email : String = "") : Nil #

Adds an entry to the mailmap.

  • real_name: the canonical name (or nil to keep original)
  • real_email: the canonical email (or nil to keep original)
  • replace_name: the name to match (or nil to match any name)
  • replace_email: the email to match (required)

[View source]
def resolve(name : String, email : String) : Tuple(String, String) #

Resolves a name and email pair through the mailmap. Returns {resolved_name, resolved_email}.


[View source]
def resolve_signature(sig : Signature) : Signature #

Resolves a Signature through the mailmap, returning a new Signature with the resolved name and email.


[View source]