Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lib/overcommit/hook/prepare_commit_msg/replace_branch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def run
Overcommit::Utils.log.debug("Writing #{commit_message_filename} with #{new_template}")

modify_commit_message do |old_contents|
"#{new_template}\n#{old_contents}"
"#{new_template} #{old_contents}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you actually want the space? Won't that result in the old contents getting a leading space, or am I misunderstanding the fix? Should we instead check if new_template has a newline and add one if it doesn't?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would want the space since the text is replaced using the replacement_text value. So unless the user consciously adds a space to the end of that value, it will not be included.

Just for reference, using git version 2.25.0, old_contents would be as follows (with the preceding newline):


# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# On branch bug/705-extra-newline
# Your branch is up to date with 'origin/bug/705-extra-newline'.
#
# Changes to be committed:
#       modified:   lib/overcommit/hook/prepare_commit_msg/replace_branch.rb
#

end

:pass
Expand Down