Skip to content

Commit f252a55

Browse files
committed
github: scripts: commit_linter: fix handling of multiple prefixes
Signed-off-by: Eduardo Silva <eduardo@chronosphere.io>
1 parent be56692 commit f252a55

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

.github/scripts/commit_prefix_check.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,19 @@ def validate_commit(commit):
213213
umbrella_prefixes = {"lib:"}
214214

215215
# If more than one non-build prefix is inferred AND the subject is not an umbrella
216-
# prefix, require split commits.
216+
# prefix, check if the subject prefix is in the expected list. If it is, allow it
217+
# (because the corresponding file exists). Only reject if it's not in the expected list
218+
# or if it's an umbrella prefix that doesn't match.
217219
if len(non_build_prefixes) > 1 and subj_lower not in umbrella_prefixes:
218-
expected_list = sorted(expected)
219-
expected_str = ", ".join(expected_list)
220-
return False, (
221-
f"Subject prefix '{subject_prefix}' does not match files changed.\n"
222-
f"Expected one of: {expected_str}"
223-
)
220+
# If subject prefix is in expected list, it's valid (the corresponding file exists)
221+
if subj_lower not in expected_lower:
222+
expected_list = sorted(expected)
223+
expected_str = ", ".join(expected_list)
224+
return False, (
225+
f"Subject prefix '{subject_prefix}' does not match files changed.\n"
226+
f"Expected one of: {expected_str}"
227+
)
228+
# Subject prefix is in expected list, so it's valid - no need to check further
224229

225230
# Subject prefix must be one of the expected ones
226231
if subj_lower not in expected_lower:

0 commit comments

Comments
 (0)