Class MailMap


  • public class MailMap
    extends Object
    An implementation of Git's .mailmap functionality
    Author:
    Sebastian Staudt
    • Constructor Detail

      • MailMap

        MailMap​(GitRepository repository)
        Creates a new mail map instance
        Parameters:
        repository - The Git repository to parse the mail map for
        See Also:
        parseMailMap()
    • Method Detail

      • exists

        public boolean exists()
        Returns whether a mail map has been found for the repository
        Returns:
        true if the mail map has been parsed from an existing .mailmap file
        See Also:
        parseMailMap()
      • getCanonicalMail

        String getCanonicalMail​(String name,
                                String mail)
        Returns the canonical email address for the given name and email address pair
        Parameters:
        name - The actual name from a commit
        mail - The actual email address from a commit
        Returns:
        The email address matching a mapping in the mail map or the initial email address
      • getCanonicalName

        String getCanonicalName​(String name,
                                String mail)
        Returns the canonical name for the given name and email address pair
        Parameters:
        name - The actual name from a commit
        mail - The actual email address from a commit
        Returns:
        The name matching a mapping in the mail map or the initial name
      • getCanonicalAuthorEmailAddress

        public String getCanonicalAuthorEmailAddress​(GitCommit commit)
        Returns the canonical email address of the author of the given commit object
        Parameters:
        commit - The commit object to get the email address from
        Returns:
        The canonical email address of the author
        See Also:
        getCanonicalMail(String, String)
      • getCanonicalAuthorName

        public String getCanonicalAuthorName​(GitCommit commit)
        Returns the canonical name of the author of the given commit object
        Parameters:
        commit - The commit object to get the name from
        Returns:
        The canonical name of the author
        See Also:
        getCanonicalName(String, String)
      • getCanonicalCommitterEmailAddress

        public String getCanonicalCommitterEmailAddress​(GitCommit commit)
        Returns the canonical email address of the committer of the given commit object
        Parameters:
        commit - The commit object to get the email address from
        Returns:
        The canonical email address of the author
        See Also:
        getCanonicalMail(String, String)
      • getCanonicalCommitterName

        public String getCanonicalCommitterName​(GitCommit commit)
        Returns the canonical name of the committer of the given commit object
        Parameters:
        commit - The commit object to get the name from
        Returns:
        The canonical name of the author
        See Also:
        getCanonicalName(String, String)
      • parseMailMap

        void parseMailMap​(File mailMap)
                   throws IOException
        Tries to parse the given file using the rules from git-shortlog.
        Lines not matching one of the valid formats are silently ignored.
        Parameters:
        mailMap - The .mailmap file to parse
        Throws:
        FileNotFoundException - if the .mailmap file does not exist
        IOException - if the .mailmap file cannot be read