Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

some refactoring of prepare commit msg

  • Loading branch information...
commit d199474c958559ce2ba0960da79b86d5c7fa34f1 1 parent 8595471
@leonid-shevtsov authored
Showing with 13 additions and 5 deletions.
  1. +13 −5 lib/pivotal_shell/commands/prepare-commit-msg-hook.rb
View
18 lib/pivotal_shell/commands/prepare-commit-msg-hook.rb
@@ -6,13 +6,12 @@ def initialize(options)
end
def execute
- commit_message_lines = @commit_message.split("\n")
- commit_message_without_comments = commit_message_lines.shift(commit_message_lines.find_index{|line| line =~ /^#/} || commit_message_lines.length)
- if commit_message_without_comments.join.strip == ''
+ parse_commit_message
+ if commit_message_empty?
File.open(@filename, 'w') do |f|
- f.puts commit_message_without_comments.join("\n")
+ f.puts @commit_message_without_comments.join("\n")
f.puts stories
- f.puts commit_message_lines.join("\n")
+ f.puts @commit_message_lines.join("\n")
end
end
end
@@ -24,5 +23,14 @@ def stories
"# #{story_id.rjust(13)} #{story.name}"
}.join("\n")
end
+
+ def parse_commit_message
+ @commit_message_lines = @commit_message.split("\n")
+ @commit_message_without_comments = @commit_message_lines.shift(@commit_message_lines.find_index{|line| line =~ /^#/} || @commit_message_lines.length)
+ end
+
+ def commit_message_empty?
+ @commit_message_without_comments.join.strip == ''
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.