sheehan created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  The regular expression for this function formerly lived at
  
https://hg.mozilla.org/hgcustom/version-control-tools/file/tip/hghooks/mozhghooks/author_format.py#l13

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D2959

AFFECTED FILES
  mercurial/utils/stringutil.py

CHANGE DETAILS

diff --git a/mercurial/utils/stringutil.py b/mercurial/utils/stringutil.py
--- a/mercurial/utils/stringutil.py
+++ b/mercurial/utils/stringutil.py
@@ -286,3 +286,25 @@
     If s is not a valid boolean, returns None.
     """
     return _booleans.get(s.lower(), None)
+
+_correctauthorformat = remod.compile('^[^<]+\s\<[^<>]+@[^<>]+\>$')
+def isauthorwellformed(author):
+    '''Return True if the author field is well formed
+    (ie "Contributor Name <cont...@email.dom>")
+
+    >>> isauthorwellformed('Good Author <g...@author.com>')
+    True
+    >>> isauthorwellformed('Author <g...@author.com>')
+    True
+    >>> isauthorwellformed('Bad Author')
+    False
+    >>> isauthorwellformed('Bad Author <aut...@author.com')
+    False
+    >>> isauthorwellformed('Bad Author aut...@author.com')
+    False
+    >>> isauthorwellformed('<aut...@author.com>')
+    False
+    >>> isauthorwellformed('Bad Author <author>')
+    False
+    '''
+    return bool(_correctauthorformat.match(author))



To: sheehan, #hg-reviewers
Cc: mercurial-devel
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to