From 51396ab512b5f454f9acc4bc133827e2b26e0f43 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Mon, 27 Feb 2023 21:11:43 +0900 Subject: 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 Reviewed-by: Laurent Pinchart --- utils/checkstyle.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'utils') 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 [] -- cgit v1.2.1