summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoris Roovers <jroovers@cisco.com>2017-05-13 20:50:53 -0400
committerJoris Roovers <jroovers@cisco.com>2017-05-13 20:50:53 -0400
commit3489743250816f415a0116b51d6c1541557a87e0 (patch)
tree13fb4aed40f43df1c70d44bbabd3768f3e61f1eb
parent0c66f6dca43eac634d37752dd41d37b7fdbec608 (diff)
Undo caching email address regex compilation
Apparently, python already caches regexes internally, so there's no need to do that again :) Details: http://stackoverflow.com/questions/12514157/ how-does-pythons-regex-pattern-caching-work
-rw-r--r--gitlint/rules.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/gitlint/rules.py b/gitlint/rules.py
index 5c38f4c..9ce2351 100644
--- a/gitlint/rules.py
+++ b/gitlint/rules.py
@@ -292,17 +292,12 @@ class AuthorValidEmail(CommitRule):
name = "author-valid-email"
id = "M1"
options_spec = [StrOption('regex', "[^@ ]+@[^@ ]+\.[^@ ]+", "Regex that author email address should match")]
- email_regex = None
-
- # Note that unicode is allowed in email addresses
- # See http://stackoverflow.com/questions/3844431/are-email-addresses-allowed-to-contain-non-alphanumeric-characters
def validate(self, commit):
+ # Note that unicode is allowed in email addresses
+ # See http://stackoverflow.com/questions/3844431
+ # /are-email-addresses-allowed-to-contain-non-alphanumeric-characters
+ email_regex = re.compile(self.options['regex'].value, re.UNICODE)
- # Only compile the regex the first time so that we don't need to re-compile it if we are linting
- # multiple commits at once
- if not self.email_regex:
- self.email_regex = re.compile(self.options['regex'].value, re.UNICODE)
-
- if commit.author_email and not self.email_regex.match(commit.author_email):
+ if commit.author_email and not email_regex.match(commit.author_email):
return [RuleViolation(self.id, "Author email for commit is invalid", commit.author_email)]