mirror of https://github.com/zulip/zulip.git
lint: Rely on core gitlint skipping of revert commits.
gitlint 0.13.0 and above skip revert commits[1]. This obviates the need for a custom rule. [1] https://jorisroovers.com/gitlint/configuration/#ignore-revert-commits
This commit is contained in:
parent
174fa0a331
commit
12ade4c49d
2
.gitlint
2
.gitlint
|
@ -3,7 +3,7 @@ ignore=title-trailing-punctuation, body-min-length, body-is-missing, title-imper
|
|||
|
||||
extra-path=tools/lib/gitlint-rules.py
|
||||
|
||||
[title-match-regex-allow-exception]
|
||||
[title-match-regex]
|
||||
regex=^(.+:\ )?[A-Z].+\.$
|
||||
|
||||
[title-max-length]
|
||||
|
|
|
@ -45,7 +45,7 @@ pyinotify
|
|||
tblib
|
||||
|
||||
# Needed to lint Git commit messages
|
||||
gitlint
|
||||
gitlint>=0.13.0
|
||||
|
||||
# Needed for visualising cprofile reports
|
||||
snakeviz
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
import re
|
||||
from typing import List
|
||||
|
||||
from gitlint.git import GitCommit
|
||||
from gitlint.options import StrOption
|
||||
from gitlint.rules import CommitMessageTitle, LineRule, RuleViolation
|
||||
|
||||
# Word list from https://github.com/m1foley/fit-commit
|
||||
|
@ -307,31 +305,10 @@ class ImperativeMood(LineRule):
|
|||
violation = RuleViolation(
|
||||
self.id,
|
||||
self.error_msg.format(
|
||||
word=first_word,
|
||||
imperative=imperative,
|
||||
title=commit.message.title,
|
||||
word=first_word, imperative=imperative, title=commit.message.title,
|
||||
),
|
||||
)
|
||||
|
||||
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: str, commit: GitCommit) -> 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 = f"Title does not match regex ({regex})"
|
||||
return [RuleViolation(self.id, violation_msg, title)]
|
||||
|
||||
return []
|
||||
|
|
Loading…
Reference in New Issue