Permalink
Browse files

Better revision message formatting.

  • Loading branch information...
1 parent fcd38b7 commit 4d0414eb62664e9e829a1709dadff7ff91739b84 @jqr jqr committed Aug 29, 2008
View
@@ -1,14 +1,14 @@
class Snitch
module Message
# Outputs a commit in a pretty format for snitch services
- def to_s(which=:long)
+ def to_s(which = :long)
case which.to_s
when 'superlong'
- "[#{project}] Revision #{revision} Committed by #{author}:\n#{message}\nChanged Files:\n#{diffs}"
+ "[#{project}] Revision #{revision} Committed by #{author}:\n - #{message}\nChanges:\n#{diffs}"
when 'long'
- "[#{project}] Revision #{revision} Committed by #{author}:\n#{message}\nChanged Files:\n#{affected}"
+ "[#{project}] Revision #{revision} Committed by #{author}:\n - #{message}\nChanged Files:\n#{affected}"
when 'short'
- str = "[#{project}] Revision #{revision} Committed by #{author}:"
+ str = "[#{project}] Revision #{revision} Committed by #{author}: "
str += message.size > 137 ? message[0, (140 - str.size)] + '...' : message
str.gsub("\n", ' ')
end
@@ -25,7 +25,7 @@ def project
end
def message
- " - #{@commit.message}"
+ @commit.message
end
def diffs
@@ -26,7 +26,7 @@ def project
end
def message
- @message ||= log.split(%r{#{LOG_PREPEND}}).inject('') { |str, log_item| str << " - #{log_item.gsub(/-/, '').capitalize}"; str }
+ @message ||= log.split(%r{#{LOG_PREPEND}}).inject('') { |str, log_item| str << log_item.gsub(/-/, '').capitalize; str }
end
def affected
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../test_helper'
+require File.dirname(__FILE__) + '/../../test_helper'
class GitTest < Test::Unit::TestCase
def setup
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../test_helper'
+require File.dirname(__FILE__) + '/../../test_helper'
# TODO: move this test to remote folder
@@ -13,19 +13,19 @@ def setup
@revision
end
-# test 'should be able to build long message' do
-# cmt_msg = <<EOF
-# [conductor] Revision 100 Committed by deploy:
-# - Drop additions
-#
-# Changed Files:
-# - U trunk/app/controllers/conductor_controller.rb
-# - A trunk/app/drops/page_drop.rb
-# - U trunk/app/drops/site_drop.rb
-# - U trunk/app/models/page.rb
-# EOF
-# assert_equal cmt_msg, @svnlook.to_s(:long)
-# end
+ test 'should be able to build long message' do
+ cmt_msg = <<EOF
+[conductor] Revision 100 Committed by deploy:
+ - Drop additions
+
+Changed Files:
+ - U trunk/app/controllers/conductor_controller.rb
+ - A trunk/app/drops/page_drop.rb
+ - U trunk/app/drops/site_drop.rb
+ - U trunk/app/models/page.rb
+EOF
+ assert_equal cmt_msg, @svnlook.to_s(:long)
+ end
#
# test 'should be able to build short message' do
# cmt_msg = "[conductor] Revision 100 Committed by deploy: - Drop additions "

0 comments on commit 4d0414e

Please sign in to comment.