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 <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2024-08-28 13:21:34 +02:00 committed by Anas Nashif
commit 2c496c094b

View file

@ -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