Skip to content
Snippets Groups Projects

mrhlpr: use Part-of trailer instead of adding MR ID to subject

Merged Caleb Connolly requested to merge caleb/use-part-of into master
Files
2
@@ -16,22 +16,43 @@ if not mrhlpr_msg_filter_mr_id:
exit(1)
line_number = 0
suffix = " (MR " + mrhlpr_msg_filter_mr_id + ")"
line_count = 0
empty_lines = 0
trailer = f"Part-of: {mrhlpr_msg_filter_mr_id}"
emit_trailer = True
have_trailers = False
for line in sys.stdin:
line = line.rstrip()
line_number += 1
line_count += 1
# Add the suffix in the first line
if line_number == 1:
if line.endswith(suffix):
print(line)
else:
print(line + suffix)
# Don't emit the trailer if the commit already has it
if line == trailer:
emit_trailer = False
else:
# Make sure we have an empty line after the first one
if line_number == 2 and line != "":
print()
# Count empty lines since the last non-empty line
if line == "":
empty_lines += 1
else:
empty_lines = 0
if any(
line.lower().startswith(prefix)
for prefix in [
"signed-off-by: ",
"co-developed-by: ",
"suggested-by: ",
"reported-by: ",
"change-id: ",
"co-authored-by: ",
"part-of: ",
]
):
have_trailers = True
print(line)
# Print all other lines without modification
print(line)
if emit_trailer:
# Print a blank line before the trailer section unless we already have trailers
if empty_lines == 0 and not have_trailers:
print()
print(trailer)
Loading