From f31f880548747433c52632dcbf839ec0aad16fce Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 6 Jan 2026 16:48:15 +0900 Subject: [PATCH 1/4] github: scripts: commit_prefix_check: Handle config_format prefix Signed-off-by: Hiroshi Hatake --- .github/scripts/commit_prefix_check.py | 40 ++++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/.github/scripts/commit_prefix_check.py b/.github/scripts/commit_prefix_check.py index b8c14c2e3c5..3a72d075536 100644 --- a/.github/scripts/commit_prefix_check.py +++ b/.github/scripts/commit_prefix_check.py @@ -62,18 +62,28 @@ def infer_prefix_from_paths(paths): component_prefixes.add(f"{parts[1]}:") # ----- src/ → flb_xxx.* → xxx: OR src// → : ----- - # ----- src/fluent-bit.c → bin: ----- + # ----- src/ handling ----- if p.startswith("src/"): + parts = p.split("/") filename = os.path.basename(p) - if filename.startswith("flb_"): + + # src/fluent-bit.c → bin: + if filename == "fluent-bit.c": + component_prefixes.add("bin:") + continue + + # src/flb_xxx.c → xxx: + if len(parts) == 2 and filename.startswith("flb_"): core = filename[4:].split(".")[0] component_prefixes.add(f"{core}:") - elif filename == "fluent-bit.c": - component_prefixes.add("bin:") - else: - parts = p.split("/") - if len(parts) > 1: - component_prefixes.add(f"{parts[1]}:") + continue + + # src//... → : + if len(parts) > 2: + src_dir = parts[1] + component_prefixes.add(f"{src_dir}:") + continue + # prefixes = component prefixes + build: if needed prefixes |= component_prefixes @@ -170,6 +180,18 @@ def validate_commit(commit): expected_lower = {p.lower() for p in expected} subj_lower = subject_prefix.lower() + # ------------------------------------------------ + # config_format strict rule: + # If config_format: exists, it MUST be used as subject + # ------------------------------------------------ + if "config_format:" in expected_lower and subj_lower != "config_format:": + expected_list = sorted(expected) + expected_str = ", ".join(expected_list) + return False, ( + f"Subject prefix '{subject_prefix}' does not match files changed.\n" + f"Expected one of: config_format:" + ) + # ------------------------------------------------ # Multiple-component detection # ------------------------------------------------ @@ -183,7 +205,7 @@ def validate_commit(commit): } # Prefixes that are allowed to cover multiple subcomponents - umbrella_prefixes = {"lib:"} + umbrella_prefixes = {"lib:", "config_format:"} # If more than one non-build prefix is inferred AND the subject is not an umbrella # prefix, require split commits. From f8b6366650caa07b17e9474d78df678e64fdeb56 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 6 Jan 2026 16:51:26 +0900 Subject: [PATCH 2/4] github: scripts: tests: Add test cases for config_format umbrella Signed-off-by: Hiroshi Hatake --- .github/scripts/tests/test_commit_lint.py | 69 +++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/.github/scripts/tests/test_commit_lint.py b/.github/scripts/tests/test_commit_lint.py index ec6b9982a03..0496e3ed641 100644 --- a/.github/scripts/tests/test_commit_lint.py +++ b/.github/scripts/tests/test_commit_lint.py @@ -622,6 +622,75 @@ def test_valid_config_file_changes(): ok, _ = validate_commit(commit) assert ok is True +# ----------------------------------------------------------- +# config_format strict rules +# ----------------------------------------------------------- + +def test_valid_config_format_commit(): + """ + When files under src/config_format are modified, the subject MUST use + the umbrella prefix 'config_format:'. + + This ensures config_format is treated as a logical subsystem rather than + exposing internal implementation names (cf_yaml, cf_fluentbit, etc.) + in commit subjects. + """ + commit = make_commit( + "config_format: cf_yaml: fix include resolution\n\nSigned-off-by: User", + ["src/config_format/flb_cf_yaml.c"] + ) + ok, _ = validate_commit(commit) + assert ok is True + + +def test_error_cf_yaml_prefix_not_allowed(): + """ + Internal implementation prefixes like 'cf_yaml:' must NOT be allowed + as commit subjects when modifying src/config_format. + + The umbrella prefix 'config_format:' must be used instead. + """ + commit = make_commit( + "cf_yaml: fix include resolution\n\nSigned-off-by: User", + ["src/config_format/flb_cf_yaml.c"] + ) + ok, msg = validate_commit(commit) + assert ok is False + assert "config_format:" in msg + + +def test_error_yaml_prefix_not_allowed(): + """ + Generic implementation prefixes like 'yaml:' must NOT be allowed + for src/config_format changes. + + This prevents leaking format-specific implementation details into + commit history. + """ + commit = make_commit( + "yaml: fix include resolution\n\nSigned-off-by: User", + ["src/config_format/flb_cf_yaml.c"] + ) + ok, msg = validate_commit(commit) + assert ok is False + assert "config_format:" in msg + + +def test_valid_config_format_multiple_files(): + """ + Modifying multiple files under src/config_format should still require + the 'config_format:' umbrella prefix. + """ + commit = make_commit( + "config_format: refactor include handling\n\nSigned-off-by: User", + [ + "src/config_format/flb_cf_yaml.c", + "src/config_format/flb_cf_fluentbit.c", + ] + ) + ok, _ = validate_commit(commit) + assert ok is True + # ----------------------------------------------------------- # Additional Tests: validate_commit Complex Scenarios From 625143e3cc3a5b2db5a389e4b27385b3242a24cb Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 6 Jan 2026 17:03:41 +0900 Subject: [PATCH 3/4] github: scripts: commit_prefix_check: Tighten the rule Signed-off-by: Hiroshi Hatake --- .github/scripts/commit_prefix_check.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/scripts/commit_prefix_check.py b/.github/scripts/commit_prefix_check.py index 3a72d075536..ca5a555c309 100644 --- a/.github/scripts/commit_prefix_check.py +++ b/.github/scripts/commit_prefix_check.py @@ -192,6 +192,22 @@ def validate_commit(commit): f"Expected one of: config_format:" ) + # ------------------------------------------------ + # config_format conditional umbrella rule + # ------------------------------------------------ + if "config_format:" in expected_lower: + non_build = { + p for p in expected_lower + if p not in ("build:", "cmakelists.txt:") + } + + # Allow ONLY if all non-build prefixes are config_format: + if non_build != {"config_format:"}: + return False, ( + f"Subject prefix '{subject_prefix}' does not match files changed.\n" + f"config_format commits must not include other components." + ) + # ------------------------------------------------ # Multiple-component detection # ------------------------------------------------ @@ -205,7 +221,7 @@ def validate_commit(commit): } # Prefixes that are allowed to cover multiple subcomponents - umbrella_prefixes = {"lib:", "config_format:"} + umbrella_prefixes = {"lib:"} # If more than one non-build prefix is inferred AND the subject is not an umbrella # prefix, require split commits. From e38f2af272ffe1d83947aa495b6d3c69b27c5f17 Mon Sep 17 00:00:00 2001 From: Hiroshi Hatake Date: Tue, 6 Jan 2026 18:23:13 +0900 Subject: [PATCH 4/4] github: scripts: commit_prefix_check: Remove needless lines Signed-off-by: Hiroshi Hatake --- .github/scripts/commit_prefix_check.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/scripts/commit_prefix_check.py b/.github/scripts/commit_prefix_check.py index ca5a555c309..a345a60eced 100644 --- a/.github/scripts/commit_prefix_check.py +++ b/.github/scripts/commit_prefix_check.py @@ -180,17 +180,6 @@ def validate_commit(commit): expected_lower = {p.lower() for p in expected} subj_lower = subject_prefix.lower() - # ------------------------------------------------ - # config_format strict rule: - # If config_format: exists, it MUST be used as subject - # ------------------------------------------------ - if "config_format:" in expected_lower and subj_lower != "config_format:": - expected_list = sorted(expected) - expected_str = ", ".join(expected_list) - return False, ( - f"Subject prefix '{subject_prefix}' does not match files changed.\n" - f"Expected one of: config_format:" - ) # ------------------------------------------------ # config_format conditional umbrella rule