Skip to content

Commit

Permalink
remove extra hard-coded space in ReplaceBranch
Browse files Browse the repository at this point in the history
This removes a trailing space after the repacement text, as well as
`#strip`ing the replacement text.
  • Loading branch information
jethrodaniel committed Aug 8, 2020
1 parent 579d8a7 commit 0bcc8dd
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/overcommit/hook/prepare_commit_msg/replace_branch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ReplaceBranch < Base
DEFAULT_BRANCH_PATTERN = /\A(\d+)-(\w+).*\z/

def run
return :pass if skipped_commit_types.include? commit_message_source
return :pass if skip?

Overcommit::Utils.log.debug(
"Checking if '#{Overcommit::GitRepo.current_branch}' matches #{branch_pattern}"
Expand All @@ -43,14 +43,14 @@ def run
Overcommit::Utils.log.debug("Writing #{commit_message_filename} with #{new_template}")

modify_commit_message do |old_contents|
"#{new_template} #{old_contents}"
"#{new_template}#{old_contents}"
end

:pass
end

def new_template
@new_template ||= Overcommit::GitRepo.current_branch.gsub(branch_pattern, replacement_text)
@new_template ||= Overcommit::GitRepo.current_branch.gsub(branch_pattern, replacement_text).strip
end

def branch_pattern
Expand Down Expand Up @@ -79,5 +79,9 @@ def replacement_text_config
def skipped_commit_types
@skipped_commit_types ||= config['skipped_commit_types'].map(&:to_sym)
end

def skip?
skipped_commit_types.include?(commit_message_source)
end
end
end

0 comments on commit 0bcc8dd

Please sign in to comment.