def test_lookup(self): m = Mailmap() m.add_entry((b"Jane Doe", b"jane@desktop.(none)"), (None, None)) m.add_entry((b"Joe R. Developer", b"*****@*****.**"), None) m.add_entry((None, b"*****@*****.**"), (None, b"*****@*****.**")) m.add_entry((b"Some Dude", b"*****@*****.**"), (b"nick1", b"*****@*****.**")) m.add_entry( (b"Other Author", b"*****@*****.**"), (b"nick2", b"*****@*****.**"), ) m.add_entry((b"Other Author", b"*****@*****.**"), (None, b"*****@*****.**")) m.add_entry( (b"Santa Claus", b"*****@*****.**"), (None, b"*****@*****.**"), ) self.assertEqual( b"Jane Doe <jane@desktop.(none)>", m.lookup(b"Jane Doe <jane@desktop.(none)>"), ) self.assertEqual( b"Jane Doe <jane@desktop.(none)>", m.lookup(b"Jane Doe <*****@*****.**>"), ) self.assertEqual( b"Jane Doe <jane@desktop.(none)>", m.lookup(b"Jane D. <jane@desktop.(none)>"), ) self.assertEqual(b"Some Dude <*****@*****.**>", m.lookup(b"nick1 <*****@*****.**>")) self.assertEqual(b"CTO <*****@*****.**>", m.lookup(b"CTO <*****@*****.**>"))
def check_mailmap(repo, contact): """Check canonical name and email of contact. :param repo: Path to the repository :param contact: Contact name and/or email :return: Canonical contact data """ with open_repo_closing(repo) as r: from dulwich.mailmap import Mailmap import errno try: mailmap = Mailmap.from_path(os.path.join(r.path, '.mailmap')) except IOError as e: if e.errno != errno.ENOENT: raise mailmap = Mailmap() return mailmap.lookup(contact)
def test_lookup(self): m = Mailmap() m.add_entry((b'Jane Doe', b'jane@desktop.(none)'), (None, None)) m.add_entry((b'Joe R. Developer', b'*****@*****.**'), None) m.add_entry((None, b'*****@*****.**'), (None, b'*****@*****.**')) m.add_entry((b'Some Dude', b'*****@*****.**'), (b'nick1', b'*****@*****.**')) m.add_entry((b'Other Author', b'*****@*****.**'), (b'nick2', b'*****@*****.**')) m.add_entry((b'Other Author', b'*****@*****.**'), (None, b'*****@*****.**')) m.add_entry((b'Santa Claus', b'*****@*****.**'), (None, b'*****@*****.**')) self.assertEqual(b'Jane Doe <jane@desktop.(none)>', m.lookup(b'Jane Doe <jane@desktop.(none)>')) self.assertEqual(b'Jane Doe <jane@desktop.(none)>', m.lookup(b'Jane Doe <*****@*****.**>')) self.assertEqual(b'Jane Doe <jane@desktop.(none)>', m.lookup(b'Jane D. <jane@desktop.(none)>')) self.assertEqual(b'Some Dude <*****@*****.**>', m.lookup(b'nick1 <*****@*****.**>')) self.assertEqual(b'CTO <*****@*****.**>', m.lookup(b'CTO <*****@*****.**>'))