ssoma-mda: Support name-less From: headers
authorW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 06:08:53 +0000 (22:08 -0800)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 06:08:53 +0000 (22:08 -0800)
For example:

  >>> email.utils.parseaddr('alice@example.net')
  ('', 'alice@example.net')

Now folks with:

  From: alice@example.net

will be stored in the Git commit as:

  "alice@example.net" <alice@example.net>

ssoma-mda

index c5aedf403207243a64d06e9c09e986fa762dcc28..99d62b154b829b055a2b1398bfd69f19bb138a84 100755 (executable)
--- a/ssoma-mda
+++ b/ssoma-mda
@@ -220,6 +220,8 @@ def get_author(message):
     """Create a pygit2.Signature for the message author."""
     author_name, author_email = _email_utils.parseaddr(
         message['From'])
+    if not author_name:
+        author_name = author_email.split('@')[0]
     date = message['Date']
     datetime = _email_utils.parsedate_to_datetime(date)
     time = int(datetime.timestamp())