Skip to content

Commit

Permalink
amend: Correctly strip comments with no trailing newline
Browse files Browse the repository at this point in the history
Revup's default COMMIT_EDITMSG does not have a trailing newline; as a
result, the regex used for matching comment lines when cleanup_type is
'strip' will not match the last line in the message and can leave a
trailing comment line. Fix this by making the trailing newline
optional in the regex.

Fixes: 24012d1 ("amend: respect git config commit.cleanup")
Signed-off-by: Brian Kubisiak <brian@kubisiak.com>
  • Loading branch information
velentr authored and jerry-skydio committed Mar 18, 2024
1 parent d29851a commit cf46831
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion revup/amend.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ async def invoke_editor_for_commit_msg(

if cleanup_type == "strip":
# Strip out comment lines
msg = re.sub(r"^{}.*$\n".format(comment_char), "", msg, flags=re.M)
msg = re.sub(r"^{}.*$\n?".format(comment_char), "", msg, flags=re.M)
elif cleanup_type == "scissors":
msg = msg.split(f"{comment_char} {CLEANUP_SCISSOR_LINE}")[0]

Expand Down

0 comments on commit cf46831

Please sign in to comment.