Commit bd511194 authored by Eric Davis's avatar Eric Davis

Support spaces in the files or directories in the git adapter. #6054

Contributed by Felix Schäfer

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4188 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 319849ca
......@@ -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=[]
......
......@@ -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
......
......@@ -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 !!!"
......
......@@ -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 !!!"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment