Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def deny_capital_text(text: str) -> bool:
if text in exclusions:
return False
if not text.islower():
return True
return False
for area in title_components[:-1]:
if (any(deny_capital_text(word) for word in area.split('/')) or
' ' in area):
violations += [RuleViolation(self.id, error, line_nr=1)]
error = "Summary of change, after area(s), should be capitalized"
if not title_components[-1][0].isupper():
violations += [RuleViolation(self.id, error, line_nr=1)]
return violations
def validate(self, commit):
filtered = [x for x in commit.message.body if not x.lower().startswith("signed-off-by") and x != '']
line_count = len(filtered)
min_line_count = self.options['min-line-count'].value
if line_count < min_line_count:
message = "Body has no content, should at least have {} line.".format(min_line_count)
return [RuleViolation(self.id, message, line_nr=1)]
def validate(self, title, _commit):
regex = self.options['regex'].value
pattern = re.compile(regex, re.UNICODE)
if not pattern.search(title):
violation_msg = u"Title does not match regex ({0})".format(regex)
return [RuleViolation(self.id, violation_msg, title)]
def validate(self, commit: Any) -> Optional[List[RuleViolation]]:
error = "Title does not end with a '.' character"
if not commit.message.title.endswith("."):
return [RuleViolation(self.id, error, line_nr=1)]
def validate(self, commit):
violations = []
for needs_mentioned_file in self.options['files'].value:
# if a file that we need to look out for is actually changed, then check whether it occurs
# in the commit msg body
if needs_mentioned_file in commit.changed_files:
if needs_mentioned_file not in " ".join(commit.message.body):
violation_message = u"Body does not mention changed file '{0}'".format(needs_mentioned_file)
violations.append(RuleViolation(self.id, violation_message, None, len(commit.message.body) + 1))
return violations if violations else None
def validate(self, line, _commit):
max_length = self.options['line-length'].value
if len(line) > max_length:
return [RuleViolation(self.id, self.violation_message.format(len(line), max_length), line)]
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 []
def validate(self, commit):
for line in commit.message.body:
if line.startswith("Signed-Off-By"):
return []
return [RuleViolation(self.id, "Body does not contain a 'Signed-Off-By' line", line_nr=1)]
def validate(self, commit):
violations = []
allowed_branch_prefixes = self.options['branch-prefixes'].value
for branch in commit.branches:
valid_branch_name = False
for allowed_prefix in allowed_branch_prefixes:
if branch.startswith(allowed_prefix):
valid_branch_name = True
break
if not valid_branch_name:
msg = "Branch name '{0}' does not start with one of {1}".format(branch,
utils.sstr(allowed_branch_prefixes))
violations.append(RuleViolation(self.id, msg, line_nr=1))
return violations
def validate(self, line, _commit):
violations = []
for commit_type in self.options["types"].value:
if line.startswith(ustr(commit_type)):
break
else:
msg = u"Title does not start with one of {0}".format(', '.join(self.options['types'].value))
violations.append(RuleViolation(self.id, msg, line))
if not RULE_REGEX.match(line):
msg = u"Title does not follow ConventionalCommits.org format 'type(optional-scope): description'"
violations.append(RuleViolation(self.id, msg, line))
return violations