Skip to content
Snippets Groups Projects
Commit c753d8f3 authored by Christopher Bohn's avatar Christopher Bohn :thinking:
Browse files

Added option to check to explain message formatting problems

parent 394d410d
No related branches found
No related tags found
No related merge requests found
......@@ -254,6 +254,30 @@ class GitlabCommit:
return self._number_of_lines_too_long(lines, subject_line_length, message_line_length) == 0 \
and self._has_blank_line_after_subject(lines)
def detail_formatting_problems(self, subject_line_length=72, message_line_length=72) -> str:
lines: List[str] = self.get_message().rstrip('\n').split('\n')
commit_id: str = f'Commit {self.gitlab_commit.short_id}'
if self.is_well_formatted():
return f'{commit_id} is well-formatted'
else:
if self._has_blank_line_after_subject(lines):
blank_line_comment = ''
else:
blank_line_comment = 'is missing a blank line after the subject'
overlong_lines = self._number_of_lines_too_long(lines,subject_line_length,message_line_length)
if overlong_lines == 0:
overlong_line_comment = ''
elif overlong_lines == 1:
overlong_line_comment = 'has 1 line too long'
else:
overlong_line_comment = f'has {overlong_lines} lines too long'
if blank_line_comment == '' or overlong_line_comment == '':
conjunction = ''
else:
conjunction = ' and '
return f'{commit_id} {blank_line_comment}{conjunction}{overlong_line_comment}.'
# git_commit fields:
# comments
# discussions
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment