Merged r12138, r12149, r12156 and r12157 from trunk to 2.3-stable (#14931)
scm: fix annotate error with non ASCII author on Ruby 1.9 and Ruby 2.0. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.3-stable@12160 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
79f90dfba5
commit
0a25ee385f
|
@ -19,8 +19,18 @@
|
||||||
<tr class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %>">
|
<tr class="bloc-<%= revision.nil? ? 0 : colors[revision.identifier || revision.revision] %>">
|
||||||
<th class="line-num" id="L<%= line_num %>"><a href="#L<%= line_num %>"><%= line_num %></a></th>
|
<th class="line-num" id="L<%= line_num %>"><a href="#L<%= line_num %>"><%= line_num %></a></th>
|
||||||
<td class="revision">
|
<td class="revision">
|
||||||
<%= (revision.identifier ? link_to_revision(revision, @repository) : format_revision(revision)) if revision && revision != previous_revision %></td>
|
<% if revision && revision != previous_revision %>
|
||||||
<td class="author"><%= h(revision.author.to_s.split('<').first) if revision && revision != previous_revision %></td>
|
<%= revision.identifier ?
|
||||||
|
link_to_revision(revision, @repository) : format_revision(revision) %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td class="author">
|
||||||
|
<% if revision && revision != previous_revision %>
|
||||||
|
<% author = Redmine::CodesetUtil.to_utf8(revision.author.to_s,
|
||||||
|
@repository.repo_log_encoding) %>
|
||||||
|
<%= author.split('<').first %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
<td class="line-code"><pre><%= line.html_safe %></pre></td>
|
<td class="line-code"><pre><%= line.html_safe %></pre></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% line_num += 1; previous_revision = revision %>
|
<% line_num += 1; previous_revision = revision %>
|
||||||
|
|
|
@ -26,6 +26,7 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase
|
||||||
REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s
|
REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s
|
||||||
REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk")
|
REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk")
|
||||||
PRJ_ID = 3
|
PRJ_ID = 3
|
||||||
|
CHAR_1_UTF8_HEX = "\xc3\x9c"
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
User.current = nil
|
User.current = nil
|
||||||
|
@ -35,6 +36,10 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase
|
||||||
:url => REPOSITORY_PATH_TRUNK,
|
:url => REPOSITORY_PATH_TRUNK,
|
||||||
:log_encoding => 'UTF-8')
|
:log_encoding => 'UTF-8')
|
||||||
assert @repository
|
assert @repository
|
||||||
|
@char_1_utf8 = CHAR_1_UTF8_HEX.dup
|
||||||
|
if @char_1_utf8.respond_to?(:force_encoding)
|
||||||
|
@char_1_utf8.force_encoding('UTF-8')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if File.directory?(REPOSITORY_PATH)
|
if File.directory?(REPOSITORY_PATH)
|
||||||
|
@ -171,6 +176,37 @@ class RepositoriesBazaarControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if REPOSITORY_PATH.respond_to?(:force_encoding)
|
||||||
|
def test_annotate_author_non_ascii
|
||||||
|
log_encoding = nil
|
||||||
|
if Encoding.locale_charmap == "UTF-8" ||
|
||||||
|
Encoding.locale_charmap == "ISO-8859-1"
|
||||||
|
log_encoding = Encoding.locale_charmap
|
||||||
|
end
|
||||||
|
unless log_encoding.nil?
|
||||||
|
repository = Repository::Bazaar.create(
|
||||||
|
:project => @project,
|
||||||
|
:url => File.join(REPOSITORY_PATH, "author_non_ascii"),
|
||||||
|
:identifier => 'author_non_ascii',
|
||||||
|
:log_encoding => log_encoding)
|
||||||
|
assert repository
|
||||||
|
get :annotate, :id => PRJ_ID, :repository_id => 'author_non_ascii',
|
||||||
|
:path => repository_path_hash(['author-non-ascii-test.txt'])[:param]
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'annotate'
|
||||||
|
assert_select "th.line-num", :text => '1' do
|
||||||
|
assert_select "+ td.revision" do
|
||||||
|
assert_select "a", :text => '2'
|
||||||
|
assert_select "+ td.author", :text => "test #{@char_1_utf8}" do
|
||||||
|
assert_select "+ td",
|
||||||
|
:text => "author non ASCII test"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_destroy_valid_repository
|
def test_destroy_valid_repository
|
||||||
@request.session[:user_id] = 1 # admin
|
@request.session[:user_id] = 1 # admin
|
||||||
assert_equal 0, @repository.changesets.count
|
assert_equal 0, @repository.changesets.count
|
||||||
|
|
|
@ -27,6 +27,7 @@ class RepositoriesGitControllerTest < ActionController::TestCase
|
||||||
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
|
||||||
PRJ_ID = 3
|
PRJ_ID = 3
|
||||||
CHAR_1_HEX = "\xc3\x9c"
|
CHAR_1_HEX = "\xc3\x9c"
|
||||||
|
FELIX_HEX = "Felix Sch\xC3\xA4fer"
|
||||||
NUM_REV = 28
|
NUM_REV = 28
|
||||||
|
|
||||||
## Git, Mercurial and CVS path encodings are binary.
|
## Git, Mercurial and CVS path encodings are binary.
|
||||||
|
@ -50,8 +51,10 @@ class RepositoriesGitControllerTest < ActionController::TestCase
|
||||||
)
|
)
|
||||||
assert @repository
|
assert @repository
|
||||||
@char_1 = CHAR_1_HEX.dup
|
@char_1 = CHAR_1_HEX.dup
|
||||||
|
@felix_utf8 = FELIX_HEX.dup
|
||||||
if @char_1.respond_to?(:force_encoding)
|
if @char_1.respond_to?(:force_encoding)
|
||||||
@char_1.force_encoding('UTF-8')
|
@char_1.force_encoding('UTF-8')
|
||||||
|
@felix_utf8.force_encoding('UTF-8')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -546,6 +549,23 @@ class RepositoriesGitControllerTest < ActionController::TestCase
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_annotate_latin_1_author
|
||||||
|
['83ca5fd546063a3c7dc2e568ba3355661a9e2b2c', '83ca5fd546063a'].each do |r1|
|
||||||
|
get :annotate, :id => PRJ_ID,
|
||||||
|
:path => repository_path_hash([" filename with a leading space.txt "])[:param],
|
||||||
|
:rev => r1
|
||||||
|
assert_select "th.line-num", :text => '1' do
|
||||||
|
assert_select "+ td.revision" do
|
||||||
|
assert_select "a", :text => '83ca5fd5'
|
||||||
|
assert_select "+ td.author", :text => @felix_utf8 do
|
||||||
|
assert_select "+ td",
|
||||||
|
:text => "And this is a file with a leading and trailing space..."
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_revisions
|
def test_revisions
|
||||||
assert_equal 0, @repository.changesets.count
|
assert_equal 0, @repository.changesets.count
|
||||||
@repository.fetch_changesets
|
@repository.fetch_changesets
|
||||||
|
|
Loading…
Reference in New Issue