utils: checkstyle.py: Don't run commit title checker on staged commits
When creating a new commit, there is no title, so the title checker complains that the title isn't compliant and the commit cannot be created if checkstyle is run as a pre-commit hook. Fix this by skipping the title checker when run on staged changes. Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
parent
58e0b6e18c
commit
51396ab512
1 changed files with 5 additions and 0 deletions
|
@ -360,6 +360,11 @@ class TitleChecker(CommitChecker):
|
|||
def check(cls, commit, top_level):
|
||||
title = commit.title
|
||||
|
||||
# Skip the check when validating staged changes (as done through a
|
||||
# pre-commit hook) as there is no title to check in that case.
|
||||
if isinstance(commit, StagedChanges):
|
||||
return []
|
||||
|
||||
# Ignore release commits, they don't need a prefix.
|
||||
if TitleChecker.release_regex.fullmatch(title):
|
||||
return []
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue