summaryrefslogtreecommitdiff
path: root/utils/checkstyle.py
diff options
context:
space:
mode:
authorPaul Elder <paul.elder@ideasonboard.com>2023-02-27 21:11:43 +0900
committerPaul Elder <paul.elder@ideasonboard.com>2023-03-01 17:20:05 +0900
commit51396ab512b5f454f9acc4bc133827e2b26e0f43 (patch)
treea6325d0119610d9990fdc3eabf24d23601dfbf46 /utils/checkstyle.py
parent58e0b6e18c425072a47594f42fc0b61801403aca (diff)
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>
Diffstat (limited to 'utils/checkstyle.py')
-rwxr-xr-xutils/checkstyle.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/utils/checkstyle.py b/utils/checkstyle.py
index 78645410..5cc523b6 100755
--- a/utils/checkstyle.py
+++ b/utils/checkstyle.py
@@ -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 []