Class MailMap
- java.lang.Object
-
- com.github.koraktor.mavanagaiata.git.MailMap
-
public class MailMap extends Object
An implementation of Git's.mailmapfunctionality- Author:
- Sebastian Staudt
-
-
Field Summary
Fields Modifier and Type Field Description (package private) booleanexistsprivate static PatternMAIL_TO_MAIL_PATTERNprivate static PatternMAIL_TO_NAME_AND_MAIL_PATTERNprivate static PatternMAIL_TO_NAME_PATTERN(package private) static StringMAILMAP_FILE(package private) Map<String,String>mailToMailMap(package private) Map<String,Map.Entry<String,String>>mailToNameAndMailMap(package private) Map<String,String>mailToNameMapprivate static PatternNAME_AND_MAIL_TO_NAME_AND_MAIL_PATTERN(package private) Map<Map.Entry<String,String>,Map.Entry<String,String>>nameAndMailToNameAndMailMap(package private) GitRepositoryrepository
-
Constructor Summary
Constructors Constructor Description MailMap(GitRepository repository)Creates a new mail map instance
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanexists()Returns whether a mail map has been found for the repositoryStringgetCanonicalAuthorEmailAddress(GitCommit commit)Returns the canonical email address of the author of the given commit objectStringgetCanonicalAuthorName(GitCommit commit)Returns the canonical name of the author of the given commit objectStringgetCanonicalCommitterEmailAddress(GitCommit commit)Returns the canonical email address of the committer of the given commit objectStringgetCanonicalCommitterName(GitCommit commit)Returns the canonical name of the committer of the given commit object(package private) StringgetCanonicalMail(String name, String mail)Returns the canonical email address for the given name and email address pair(package private) StringgetCanonicalName(String name, String mail)Returns the canonical name for the given name and email address pair(package private) voidparseMailMap()Tries to parse the.mailmapfile from the worktree of the given repository.(package private) voidparseMailMap(File mailMap)Tries to parse the given file using the rules from git-shortlog.
-
-
-
Field Detail
-
MAILMAP_FILE
static final String MAILMAP_FILE
- See Also:
- Constant Field Values
-
MAIL_TO_MAIL_PATTERN
private static final Pattern MAIL_TO_MAIL_PATTERN
-
MAIL_TO_NAME_PATTERN
private static final Pattern MAIL_TO_NAME_PATTERN
-
MAIL_TO_NAME_AND_MAIL_PATTERN
private static final Pattern MAIL_TO_NAME_AND_MAIL_PATTERN
-
NAME_AND_MAIL_TO_NAME_AND_MAIL_PATTERN
private static final Pattern NAME_AND_MAIL_TO_NAME_AND_MAIL_PATTERN
-
exists
boolean exists
-
nameAndMailToNameAndMailMap
Map<Map.Entry<String,String>,Map.Entry<String,String>> nameAndMailToNameAndMailMap
-
repository
GitRepository repository
-
-
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:
trueif the mail map has been parsed from an existing.mailmapfile- 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 commitmail- 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 commitmail- 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() throws GitRepositoryExceptionTries to parse the.mailmapfile from the worktree of the given repository.
If the file exists and contains valid contentexists()will returntrue.- Throws:
GitRepositoryException- if the.mailmapfile cannot be read- See Also:
parseMailMap(File)
-
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.mailmapfile to parse- Throws:
FileNotFoundException- if the.mailmapfile does not existIOException- if the.mailmapfile cannot be read
-
-