mirror of https://github.com/zulip/zulip.git
parent
ddf83f65ce
commit
e1f943913a
6
.gitlint
6
.gitlint
|
@ -1,9 +1,9 @@
|
|||
[general]
|
||||
ignore=title-trailing-punctuation, body-min-length, body-is-missing
|
||||
ignore=title-trailing-punctuation, body-min-length, body-is-missing, title-imperative-mood
|
||||
|
||||
# extra-path=tools/lib/gitlint-rules.py
|
||||
extra-path=tools/lib/gitlint-rules.py
|
||||
|
||||
[title-match-regex]
|
||||
[title-match-regex-allow-exception]
|
||||
regex=^(.+:\ )?[A-Z].+\.$
|
||||
|
||||
[title-max-length]
|
||||
|
|
|
@ -2,6 +2,8 @@ from typing import Text, List
|
|||
|
||||
import gitlint
|
||||
from gitlint.rules import LineRule, RuleViolation, CommitMessageTitle
|
||||
from gitlint.options import StrOption
|
||||
import re
|
||||
|
||||
# Word list from https://github.com/m1foley/fit-commit
|
||||
# Copyright (c) 2015 Mike Foley
|
||||
|
@ -141,3 +143,23 @@ class ImperativeMood(LineRule):
|
|||
violations.append(violation)
|
||||
|
||||
return violations
|
||||
|
||||
|
||||
class TitleMatchRegexAllowException(LineRule):
|
||||
"""Allows revert commits contrary to the built-in title-match-regex rule"""
|
||||
|
||||
name = 'title-match-regex-allow-exception'
|
||||
id = 'Z2'
|
||||
target = CommitMessageTitle
|
||||
options_spec = [StrOption('regex', ".*", "Regex the title should match")]
|
||||
|
||||
def validate(self, title, commit):
|
||||
# type: (Text, gitlint.commit) -> List[RuleViolation]
|
||||
|
||||
regex = self.options['regex'].value
|
||||
pattern = re.compile(regex, re.UNICODE)
|
||||
if not pattern.search(title) and not title.startswith("Revert \""):
|
||||
violation_msg = u"Title does not match regex ({0})".format(regex)
|
||||
return [RuleViolation(self.id, violation_msg, title)]
|
||||
|
||||
return []
|
||||
|
|
Loading…
Reference in New Issue