mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-03 06:09:41 +00:00
scm: git: fix non ascii branch and tag browsing (#16881)
git-svn-id: http://svn.redmine.org/redmine/trunk@18042 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
d9799f25a3
commit
ec557a67a4
@ -138,7 +138,8 @@ module Redmine
|
||||
entries = Entries.new
|
||||
cmd_args = %w|ls-tree -l|
|
||||
identifier = 'HEAD' if identifier.nil?
|
||||
cmd_args << "#{identifier}:#{p}"
|
||||
git_identifier = scm_iconv(@path_encoding, 'UTF-8', identifier)
|
||||
cmd_args << "#{git_identifier}:#{p}"
|
||||
git_cmd(cmd_args) do |io|
|
||||
io.each_line do |line|
|
||||
e = line.chomp.to_s
|
||||
@ -204,8 +205,14 @@ module Redmine
|
||||
revisions = []
|
||||
if identifier_from || identifier_to
|
||||
revisions << +""
|
||||
revisions[0] << "#{identifier_from}.." if identifier_from
|
||||
revisions[0] << "#{identifier_to}" if identifier_to
|
||||
if identifier_from
|
||||
git_identifier_from = scm_iconv(@path_encoding, 'UTF-8', identifier_from)
|
||||
revisions[0] << "#{git_identifier_from}.." if identifier_from
|
||||
end
|
||||
if identifier_to
|
||||
git_identifier_to= scm_iconv(@path_encoding, 'UTF-8', identifier_to)
|
||||
revisions[0] << "#{git_identifier_to}" if identifier_to
|
||||
end
|
||||
else
|
||||
unless options[:includes].blank?
|
||||
revisions += options[:includes]
|
||||
@ -334,8 +341,9 @@ module Redmine
|
||||
|
||||
def annotate(path, identifier=nil)
|
||||
identifier = 'HEAD' if identifier.blank?
|
||||
git_identifier = scm_iconv(@path_encoding, 'UTF-8', identifier)
|
||||
cmd_args = %w|blame --encoding=UTF-8|
|
||||
cmd_args << "-p" << identifier << "--" << scm_iconv(@path_encoding, 'UTF-8', path)
|
||||
cmd_args << "-p" << git_identifier << "--" << scm_iconv(@path_encoding, 'UTF-8', path)
|
||||
blame = Annotate.new
|
||||
content = nil
|
||||
git_cmd(cmd_args) { |io| io.binmode; content = io.read }
|
||||
@ -367,8 +375,9 @@ module Redmine
|
||||
|
||||
def cat(path, identifier=nil)
|
||||
identifier = 'HEAD' if identifier.nil?
|
||||
git_identifier = scm_iconv(@path_encoding, 'UTF-8', identifier)
|
||||
cmd_args = %w|show --no-color|
|
||||
cmd_args << "#{identifier}:#{scm_iconv(@path_encoding, 'UTF-8', path)}"
|
||||
cmd_args << "#{git_identifier}:#{scm_iconv(@path_encoding, 'UTF-8', path)}"
|
||||
cat = nil
|
||||
git_cmd(cmd_args) do |io|
|
||||
io.binmode
|
||||
|
||||
@ -225,6 +225,25 @@ class GitAdapterTest < ActiveSupport::TestCase
|
||||
assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs2[-1].identifier
|
||||
end
|
||||
|
||||
def test_revisions_latin_1_identifier
|
||||
if WINDOWS_PASS
|
||||
puts WINDOWS_SKIP_STR
|
||||
elsif JRUBY_SKIP
|
||||
puts JRUBY_SKIP_STR
|
||||
else
|
||||
revs1 = []
|
||||
@adapter.revisions('',
|
||||
"latin-1-branch-#{@char_1}-01",
|
||||
"latin-1-branch-#{@char_1}-02",
|
||||
{:reverse => true}) do |rev|
|
||||
revs1 << rev
|
||||
end
|
||||
end
|
||||
assert_equal 2, revs1.length
|
||||
assert_equal '64f1f3e89ad1cb57976ff0ad99a107012ba3481d', revs1[ 0].identifier
|
||||
assert_equal '1ca7f5ed374f3cb31a93ae5215c2e25cc6ec5127', revs1[ 1].identifier
|
||||
end
|
||||
|
||||
def test_revisions_invalid_rev
|
||||
assert_equal [], @adapter.revisions('', '1234abcd', "master")
|
||||
assert_raise Redmine::Scm::Adapters::CommandFailed do
|
||||
@ -384,6 +403,23 @@ class GitAdapterTest < ActiveSupport::TestCase
|
||||
assert_equal "jsmith", annotate.revisions[4].author
|
||||
end
|
||||
|
||||
def test_annotate_latin_1_identifier
|
||||
if WINDOWS_PASS
|
||||
puts WINDOWS_SKIP_STR
|
||||
elsif JRUBY_SKIP
|
||||
puts JRUBY_SKIP_STR
|
||||
else
|
||||
annotate = @adapter.annotate('sources/watchers_controller.rb',
|
||||
"latin-1-branch-#{@char_1}-02")
|
||||
assert_equal 40, annotate.lines.size
|
||||
assert_equal "# This program is free software; you can redistribute it and/or",
|
||||
annotate.lines[3].strip
|
||||
assert_equal "7234cb2750b63f47bff735edc50a1c0a433c2518",
|
||||
annotate.revisions[3].identifier
|
||||
assert_equal "jsmith", annotate.revisions[3].author
|
||||
end
|
||||
end
|
||||
|
||||
def test_annotate_moved_file
|
||||
annotate = @adapter.annotate('renamed_test.txt')
|
||||
assert_kind_of Redmine::Scm::Adapters::Annotate, annotate
|
||||
@ -519,6 +555,23 @@ class GitAdapterTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def test_entries_latin_1_identifier
|
||||
if WINDOWS_PASS
|
||||
puts WINDOWS_SKIP_STR
|
||||
elsif JRUBY_SKIP
|
||||
puts JRUBY_SKIP_STR
|
||||
else
|
||||
entries1 = @adapter.entries(nil,
|
||||
"latin-1-branch-#{@char_1}-02")
|
||||
assert entries1
|
||||
assert_equal 4, entries1.size
|
||||
f1 = entries1[0]
|
||||
assert_equal "images", f1.name
|
||||
assert_equal "images", f1.path
|
||||
assert_equal 'dir', f1.kind
|
||||
end
|
||||
end
|
||||
|
||||
def test_entry
|
||||
entry = @adapter.entry()
|
||||
assert_equal "", entry.path
|
||||
@ -565,6 +618,17 @@ class GitAdapterTest < ActiveSupport::TestCase
|
||||
assert_equal "UTF-8", adpt2.path_encoding
|
||||
end
|
||||
|
||||
def test_cat_latin_1_identifier
|
||||
if WINDOWS_PASS
|
||||
puts WINDOWS_SKIP_STR
|
||||
elsif JRUBY_SKIP
|
||||
puts JRUBY_SKIP_STR
|
||||
else
|
||||
assert @adapter.cat('sources/watchers_controller.rb',
|
||||
"latin-1-branch-#{@char_1}-02")
|
||||
end
|
||||
end
|
||||
|
||||
def test_cat_path_invalid
|
||||
assert_nil @adapter.cat('invalid')
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user