]> source.dussan.org Git - redmine.git/commitdiff
Support spaces in the files or directories in the git adapter. #6054
authorEric Davis <edavis@littlestreamsoftware.com>
Sun, 26 Sep 2010 19:07:46 +0000 (19:07 +0000)
committerEric Davis <edavis@littlestreamsoftware.com>
Sun, 26 Sep 2010 19:07:46 +0000 (19:07 +0000)
Contributed by Felix Schäfer

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4188 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/scm/adapters/git_adapter.rb
test/fixtures/repositories/git_repository.tar.gz
test/functional/repositories_git_controller_test.rb
test/unit/lib/redmine/scm/adapters/git_adapter_test.rb
test/unit/repository_git_test.rb

index 9a79bbb07df35b142559dfe421bcdb492d34a058..f455a57f58870ce753b08af2dbd5d8373c218377 100644 (file)
@@ -88,7 +88,7 @@ module Redmine
           return nil if path.nil?
           cmd = "#{GIT_BIN} --git-dir #{target('')} log --date=iso --pretty=fuller --no-merges -n 1 "
           cmd << " #{shell_quote rev} " if rev 
-          cmd <<  "-- #{path} " unless path.empty?
+          cmd <<  "-- #{shell_quote path} " unless path.empty?
           shellout(cmd) do |io|
             begin
               id = io.gets.split[1]
@@ -121,7 +121,7 @@ module Redmine
           cmd << "#{shell_quote(identifier_from + '..')}" if identifier_from
           cmd << "#{shell_quote identifier_to}" if identifier_to
           cmd << " --since=#{shell_quote(options[:since].strftime("%Y-%m-%d %H:%M:%S"))}" if options[:since]
-          cmd << " -- #{path}" if path && !path.empty?
+          cmd << " -- #{shell_quote path}" if path && !path.empty?
 
           shellout(cmd) do |io|
             files=[]
index 8158d583244a12064c1d48d20eb64427d56d3159..8a07a230cc9202a7396d5f4ed6e207087ec63d03 100644 (file)
Binary files a/test/fixtures/repositories/git_repository.tar.gz and b/test/fixtures/repositories/git_repository.tar.gz differ
index 317261a13d63988496301f9b2470437d51c7940b..bea9663c29612662bf8001f71c8a249e39864b70 100644 (file)
@@ -50,7 +50,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase
       assert_response :success
       assert_template 'show'
       assert_not_nil assigns(:entries)
-      assert_equal 7, assigns(:entries).size
+      assert_equal 8, assigns(:entries).size
       assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
       assert assigns(:entries).detect {|e| e.name == 'this_is_a_really_long_and_verbose_directory_name' && e.kind == 'dir'}
       assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
@@ -58,6 +58,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase
       assert assigns(:entries).detect {|e| e.name == 'copied_README' && e.kind == 'file'}
       assert assigns(:entries).detect {|e| e.name == 'new_file.txt' && e.kind == 'file'}
       assert assigns(:entries).detect {|e| e.name == 'renamed_test.txt' && e.kind == 'file'}
+      assert assigns(:entries).detect {|e| e.name == 'filemane with spaces.txt' && e.kind == 'file'}
     end
 
     def test_browse_branch
index f51d4a31f1be92a993e496d6ab5cd2b6fe1c02e1..76dca9ed6e79ec4f19e4cc26d1d1128cdf3297b8 100644 (file)
@@ -13,13 +13,17 @@ class GitAdapterTest < ActiveSupport::TestCase
     end
 
     def test_getting_all_revisions
-      assert_equal 13, @adapter.revisions('',nil,nil,:all => true).length
+      assert_equal 14, @adapter.revisions('',nil,nil,:all => true).length
     end
     
     def test_getting_certain_revisions
       assert_equal 1, @adapter.revisions('','899a15d^','899a15d').length
     end
     
+    def test_getting_revisions_with_spaces_in_filename
+      assert_equal 1, @adapter.revisions("filemane with spaces.txt", nil, nil, :all => true).length
+    end
+    
     def test_annotate
       annotate = @adapter.annotate('sources/watchers_controller.rb')
       assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
@@ -29,6 +33,12 @@ class GitAdapterTest < ActiveSupport::TestCase
       assert_equal "jsmith", annotate.revisions[4].author
     end
     
+    def test_annotate_moved_file
+      annotate = @adapter.annotate('renamed_test.txt')
+      assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
+      assert_equal 2, annotate.lines.size
+    end
+    
     def test_last_rev
       last_rev = @adapter.lastrev("README", "4f26664364207fa8b1af9f8722647ab2d4ac5d43")
       assert_equal "4a07fe31bffcf2888791f3e6cbc9c4545cefe3e8", last_rev.scmid
@@ -37,10 +47,12 @@ class GitAdapterTest < ActiveSupport::TestCase
       assert_equal "2009-06-24 05:27:38".to_time, last_rev.time
     end
     
-    def test_annotate_moved_file
-      annotate = @adapter.annotate('renamed_test.txt')
-      assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
-      assert_equal 2, annotate.lines.size
+    def test_last_rev_with_spaces_in_filename
+      last_rev = @adapter.lastrev("filemane with spaces.txt", "ed5bb786bbda2dee66a2d50faf51429dbc043a7b")
+      assert_equal "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", last_rev.scmid
+      assert_equal "ed5bb786bbda2dee66a2d50faf51429dbc043a7b", last_rev.identifier
+      assert_equal "Felix Schäfer <felix@fachschaften.org>", last_rev.author
+      assert_equal "2010-09-18 19:59:46".to_time, last_rev.time
     end
   else
     puts "Git test repository NOT FOUND. Skipping unit tests !!!"
index dad5610aee8b3ca008f1030ea91b3fa4a5642dd7..4f60875111b629d94fc99fc925f405d686fd8bb6 100644 (file)
@@ -34,8 +34,8 @@ class RepositoryGitTest < ActiveSupport::TestCase
       @repository.fetch_changesets
       @repository.reload
       
-      assert_equal 13, @repository.changesets.count
-      assert_equal 22, @repository.changes.count
+      assert_equal 14, @repository.changesets.count
+      assert_equal 23, @repository.changes.count
       
       commit = @repository.changesets.find(:first, :order => 'committed_on ASC')
       assert_equal "Initial import.\nThe repository contains 3 files.", commit.comments
@@ -57,10 +57,10 @@ class RepositoryGitTest < ActiveSupport::TestCase
       # Remove the 3 latest changesets
       @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy)
       @repository.reload
-      assert_equal 10, @repository.changesets.count
+      assert_equal 11, @repository.changesets.count
       
       @repository.fetch_changesets
-      assert_equal 13, @repository.changesets.count
+      assert_equal 14, @repository.changesets.count
     end
   else
     puts "Git test repository NOT FOUND. Skipping unit tests !!!"