Skip to content

Commit

Permalink
Fixing subversion support by chomping and re-enabling long message te…
Browse files Browse the repository at this point in the history
…st for subversion.
  • Loading branch information
jqr committed Aug 29, 2008
1 parent 4d0414e commit cfcf0a1
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 16 deletions.
8 changes: 5 additions & 3 deletions lib/snitch/revisions/git.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,14 +1,16 @@
class Snitch class Snitch
module Revisions module Revisions
class Git < Revision class Git < Revision
attr_accessor :repository

include Message include Message
gem 'mojombo-grit' gem 'mojombo-grit'
require 'mojombo-grit' require 'mojombo-grit'


def initialize(repository_path, revision = nil) def initialize(repository_path, revision = nil)
super super
@repository = Grit::Repo.new(repository_path) self.repository = Grit::Repo.new(repository_path)
@commit = revision ? @repository.commit( revision ) : @repository.commits.first @commit = revision ? repository.commit( revision ) : repository.commits.first
end end


# Only show the first 7 digits of the yucky SHA hash # Only show the first 7 digits of the yucky SHA hash
Expand All @@ -21,7 +23,7 @@ def author
end end


def project def project
@repository.description repository.description
end end


def message def message
Expand Down
2 changes: 1 addition & 1 deletion lib/snitch/revisions/subversion.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Subversion < Revision


def initialize(repository_path, revision) def initialize(repository_path, revision)
super super
@svnlook = `which svnlook` @svnlook = `which svnlook`.chomp
end end


# Creates a few helper methods for looking at the subversion commit # Creates a few helper methods for looking at the subversion commit
Expand Down
2 changes: 1 addition & 1 deletion test/test_helper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ def expect(expected_value, &block)


def create_subversion_repository_and_checkout def create_subversion_repository_and_checkout
`svnadmin create test-subversion-repository && svn checkout file://$PWD/test-subversion-repository/ test-subversion-checkout && cd ./test-subversion-checkout && touch test && svn add test && svn commit -m 'Initial subversion import.'` `svnadmin create test-subversion-repository && svn checkout file://$PWD/test-subversion-repository/ test-subversion-checkout && cd ./test-subversion-checkout && touch test && svn add test && svn commit -m 'Initial subversion import.'`
[`echo $PWD/test-subversion-repository`, `echo $PWD/test-subversion-checkout`] [`echo $PWD/test-subversion-repository`.chomp, `echo $PWD/test-subversion-checkout`.chomp]
end end
4 changes: 2 additions & 2 deletions test/unit/revisions/git_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ def setup
end end


test 'should have a description' do test 'should have a description' do
assert_match /^Unnamed repository/, @gitcommit.project assert_match(/^Unnamed repository/, @gitcommit.project)
end end


test 'should have diffs' do test 'should have diffs' do
assert @gitcommit.diffs assert @gitcommit.diffs
end end


test 'should have a message' do test 'should have a message' do
assert_equal ' - Initial git import.', @gitcommit.message assert_equal 'Initial git import.', @gitcommit.message
end end


test 'should have a commit' do test 'should have a commit' do
Expand Down
15 changes: 6 additions & 9 deletions test/unit/revisions/subversion_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


# TODO: move this test to remote folder # TODO: move this test to remote folder


class SubersionTest < Test::Unit::TestCase class SubversionTest < Test::Unit::TestCase
def setup def setup
# Creates a test subversion repo locally and makes a test commit to it # Creates a test subversion repo locally and makes a test commit to it
repo, checkout = create_subversion_repository_and_checkout repo, checkout = create_subversion_repository_and_checkout
Expand All @@ -15,18 +15,15 @@ def setup


test 'should be able to build long message' do test 'should be able to build long message' do
cmt_msg = <<EOF cmt_msg = <<EOF
[conductor] Revision 100 Committed by deploy: [snitch] Revision 1 Committed by #{ENV['USER']}:
- Drop additions - Initial subversion import.
Changed Files: Changed Files:
- U trunk/app/controllers/conductor_controller.rb - A test
- A trunk/app/drops/page_drop.rb
- U trunk/app/drops/site_drop.rb
- U trunk/app/models/page.rb
EOF EOF
assert_equal cmt_msg, @svnlook.to_s(:long) assert_equal cmt_msg, @revision.to_s(:long)
end end
#
# test 'should be able to build short message' do # test 'should be able to build short message' do
# cmt_msg = "[conductor] Revision 100 Committed by deploy: - Drop additions " # cmt_msg = "[conductor] Revision 100 Committed by deploy: - Drop additions "
# assert_equal cmt_msg, @svnlook.to_s(:short) # assert_equal cmt_msg, @svnlook.to_s(:short)
Expand Down

0 comments on commit cfcf0a1

Please sign in to comment.