Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit 7098138

Browse files
committed
feat: Add support for bulleted lists in body
The body now supports bulleted lists. It follows the following rules: - Either an asterisk (*) or dash (-) can be used to denote the start of a bulleted line. - The bullet symbol must be the first non-whitespace character on a line. - All previous whitespace before the symbol is ignored. This means there is no support for nested lists. - For long lines, text will be automatically wrapped and indented to ensure that it is aligned with the text on the first and previous lines. - It will always ensure there is precisely one space before and after the bullet character, followed immediately by the text of the line. Resolve #20
1 parent 4920482 commit 7098138

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

gitcommit/gitcommit.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,21 @@ def add_body(commit_msg):
300300
if num_blank_lines > 1:
301301
continue # ignore any blank lines after the first
302302
else:
303+
# check if we are dealing with a bulleted line
304+
bulleted_line = False
305+
if l_stripped[0] in ["*", "-"]:
306+
bulleted_line = True
307+
line_after_bullet = l_stripped[1:].strip()
308+
l_stripped = " " + l_stripped[0] + " " + line_after_bullet
309+
303310
# format each line with forced line breaks to maintain maximum line length
304311
wrapped_line = "\n".join(
305-
textwrap.wrap(l_stripped, width=72, break_long_words=False)
312+
textwrap.wrap(
313+
l_stripped,
314+
width=72,
315+
break_long_words=False,
316+
subsequent_indent=" " if bulleted_line else "",
317+
)
306318
)
307319
condensed_b_lines.append(wrapped_line)
308320

0 commit comments

Comments
 (0)