Dulwich.io dulwich / dd07fa9
Allow configured email addresses to be pre-quoted as "<...>". (#722) Allow configured email addresses to be pre-quoted as "<...>". monnerat authored 28 days ago Jelmer Vernooń≥ committed 28 days ago
2 changed file(s) with 7 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
3333 import sys
3434 import stat
3535 import time
36 import re
3637
3738 from dulwich.errors import (
3839 NoIndexPresent,
111112
112113 DEFAULT_REF = b'refs/heads/master'
113114
115 quoted_email_re = re.compile(br"^\s*<\s*(.*)\s*>\s*$")
116
114117
115118 class InvalidUserIdentity(Exception):
116119 """User identity is not of the format 'user <email>'"""
174177 email = default_email
175178 if not isinstance(email, bytes):
176179 email = email.encode('utf-8')
180 m = quoted_email_re.match(email)
181 if m:
182 email = m.group(1)
177183 return (user + b" <" + email + b">")
178184
179185
881881 r = self._repo
882882 c = r.get_config()
883883 c.set((b"user", ), b"name", b"Jelmer")
884 c.set((b"user", ), b"email", b"jelmer@apache.org")
884 c.set((b"user", ), b"email", b"<jelmer@apache.org>")
885885 c.write_to_path()
886886 commit_sha = r.do_commit(b'message')
887887 self.assertEqual(