From 2c496c094bfac8ed4ee4d862f75fd7e70ff864a7 Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Wed, 28 Aug 2024 13:21:34 +0200 Subject: [PATCH] scripts: ci: Fix clang-format compliance for additions or removals If a diff only has added or removed lines we need to match both '-' and '+' characters in the hunk context. Signed-off-by: Pieter De Gendt --- scripts/ci/check_compliance.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ci/check_compliance.py b/scripts/ci/check_compliance.py index e8f79a9f0c7..c8fb4bfd753 100755 --- a/scripts/ci/check_compliance.py +++ b/scripts/ci/check_compliance.py @@ -303,8 +303,8 @@ class ClangFormatCheck(ComplianceTest): for patch in patchset: for hunk in patch: # Strip the before and after context - before = next(i for i,v in enumerate(hunk) if str(v).startswith('-')) - after = next(i for i,v in enumerate(reversed(hunk)) if str(v).startswith('+')) + before = next(i for i,v in enumerate(hunk) if str(v).startswith(('-', '+'))) + after = next(i for i,v in enumerate(reversed(hunk)) if str(v).startswith(('-', '+'))) msg = "".join([str(l) for l in hunk[before:-after or None]]) # show the hunk at the last line