Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/scripts/commit_prefix_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ def infer_prefix_from_paths(paths):
component_prefixes.add(f"{parts[1]}:")

# ----- src/ → flb_xxx.* → xxx: OR src/<dir>/ → <dir>: -----
# ----- src/fluent-bit.c → bin: -----
if p.startswith("src/"):
filename = os.path.basename(p)
if 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:
Expand Down
25 changes: 25 additions & 0 deletions .github/scripts/tests/test_commit_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ def test_infer_multiple_prefixes():
# At least one real component touched → build is optional
assert build_optional is True

def test_infer_prefix_fluent_bit_entrypoint():
"""
Test that src/fluent-bit.c infers bin: prefix.

fluent-bit.c is the main entry point of the fluent-bit binary,
so commits touching this file should allow the 'bin:' prefix.
"""
prefixes, build_optional = infer_prefix_from_paths(["src/fluent-bit.c"])
assert prefixes == {"bin:"}
assert build_optional is True

# -----------------------------------------------------------
# Tests: Bad Squash Detection
Expand Down Expand Up @@ -158,6 +168,21 @@ def test_valid_commit_multiple_signoffs_allowed():
assert ok is True


def test_valid_commit_bin_prefix_for_fluent_bit():
"""
Test that commits modifying src/fluent-bit.c allow the 'bin:' prefix.

The fluent-bit.c file represents the binary entry point, so using
'bin:' as the commit prefix should be valid.
"""
commit = make_commit(
"bin: adjust startup behavior\n\nSigned-off-by: User",
["src/fluent-bit.c"]
)
ok, _ = validate_commit(commit)
assert ok is True


# -----------------------------------------------------------
# Tests: validate_commit ERROR CASES
# -----------------------------------------------------------
Expand Down
Loading