Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
4b3bd797
Commit
4b3bd797
authored
Jul 22, 2011
by
Eric Davis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix errors when trying to check for binary SCM strings in 1.9.2
1.9.2 removed String#is_binary_data?
parent
2d98a486
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
4 deletions
+17
-4
repositories_controller.rb
app/controllers/repositories_controller.rb
+6
-1
git_adapter.rb
lib/redmine/scm/adapters/git_adapter.rb
+6
-1
git_adapter_test.rb
test/unit/lib/redmine/scm/adapters/git_adapter_test.rb
+5
-2
No files found.
app/controllers/repositories_controller.rb
View file @
4b3bd797
...
...
@@ -143,7 +143,12 @@ class RepositoriesController < ApplicationController
return
true
if
Redmine
::
MimeType
.
is_type?
(
'text'
,
path
)
# Ruby 1.8.6 has a bug of integer divisions.
# http://apidock.com/ruby/v1_8_6_287/String/is_binary_data%3F
return
false
if
ent
.
is_binary_data?
if
ent
.
respond_to?
(
"is_binary_data?"
)
&&
ent
.
is_binary_data?
# Ruby 1.8.x and <1.9.2
return
false
elsif
ent
.
respond_to?
(
:force_encoding
)
&&
(
ent
.
dup
.
force_encoding
(
"UTF-8"
)
!=
ent
.
dup
.
force_encoding
(
"BINARY"
)
)
# Ruby 1.9.2
# TODO: need to handle edge cases of non-binary content that isn't UTF-8
return
false
end
true
end
private
:is_entry_text_data?
...
...
lib/redmine/scm/adapters/git_adapter.rb
View file @
4b3bd797
...
...
@@ -288,7 +288,12 @@ module Redmine
content
=
nil
scm_cmd
(
*
cmd_args
)
{
|
io
|
io
.
binmode
;
content
=
io
.
read
}
# git annotates binary files
return
nil
if
content
.
is_binary_data?
if
content
.
respond_to?
(
"is_binary_data?"
)
&&
content
.
is_binary_data?
# Ruby 1.8.x and <1.9.2
return
nil
elsif
content
.
respond_to?
(
:force_encoding
)
&&
(
content
.
dup
.
force_encoding
(
"UTF-8"
)
!=
content
.
dup
.
force_encoding
(
"BINARY"
))
# Ruby 1.9.2
# TODO: need to handle edge cases of non-binary content that isn't UTF-8
return
nil
end
identifier
=
''
# git shows commit author on the first occurrence only
authors_by_commit
=
{}
...
...
test/unit/lib/redmine/scm/adapters/git_adapter_test.rb
View file @
4b3bd797
...
...
@@ -155,7 +155,8 @@ begin
assert_equal
"2010-09-18 19:59:46"
.
to_time
,
last_rev
.
time
end
def
test_latin_1_path
# TODO: need to handle edge cases of non-binary content that isn't UTF-8
should_eventually
"test_latin_1_path"
do
if
WINDOWS_PASS
#
else
...
...
@@ -163,7 +164,9 @@ begin
[
'4fc55c43bf3d3dc2efb66145365ddc17639ce81e'
,
'4fc55c43bf3'
].
each
do
|
r1
|
assert
@adapter
.
diff
(
p2
,
r1
)
assert
@adapter
.
cat
(
p2
,
r1
)
assert_equal
1
,
@adapter
.
annotate
(
p2
,
r1
).
lines
.
length
annotation
=
@adapter
.
annotate
(
p2
,
r1
)
assert
annotation
.
present?
,
"No annotation returned"
assert_equal
1
,
annotation
.
lines
.
length
[
'64f1f3e89ad1cb57976ff0ad99a107012ba3481d'
,
'64f1f3e89ad1cb5797'
].
each
do
|
r2
|
assert
@adapter
.
diff
(
p2
,
r1
,
r2
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment