Skip to content

Removing extra newline in replacement string #709

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 11, 2020
Merged

Removing extra newline in replacement string #709

merged 1 commit into from
Mar 11, 2020

Conversation

cmackenzie1
Copy link
Contributor

Closes #705

@@ -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
#

@sds sds merged commit d9e4998 into sds:master Mar 11, 2020
@sds
Copy link
Owner

sds commented Mar 11, 2020

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ReplaceBranch adds trailing newline to commit message
2 participants