Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
80ddd2c0
Commit
80ddd2c0
authored
Apr 05, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Better encoding handling. Updated grit
parent
3706a974
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
6 deletions
+29
-6
Gemfile.lock
Gemfile.lock
+2
-2
app/controllers/commits_controller.rb
app/controllers/commits_controller.rb
+1
-0
config/initializers/gitlabhq/20_grit_ext.rb
config/initializers/gitlabhq/20_grit_ext.rb
+26
-4
No files found.
Gemfile.lock
View file @
80ddd2c0
...
...
@@ -14,7 +14,7 @@ GIT
GIT
remote: https://github.com/gitlabhq/grit.git
revision:
ff015074ef35bd94cba943f9c0f98e161ab5851c
revision:
3fc864f3c637e06e2fa7a81f6b48a5df58a9bc5b
specs:
grit (2.4.1)
diff-lcs (~> 1.1)
...
...
@@ -148,7 +148,7 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
method_source (0.7.0)
mime-types (1.1
7.2
)
mime-types (1.1
8
)
modularity (0.6.1)
multi_json (1.0.4)
multi_xml (0.4.1)
...
...
app/controllers/commits_controller.rb
View file @
80ddd2c0
require
'benchmark'
require
"base64"
class
CommitsController
<
ApplicationController
...
...
config/initializers/gitlabhq/20_grit_ext.rb
View file @
80ddd2c0
...
...
@@ -17,13 +17,35 @@ Grit::GitRuby::Internal::RawObject.class_eval do
end
private
def
transcoding
(
content
)
content
||=
""
detection
=
CharlockHolmes
::
EncodingDetector
.
detect
(
content
)
if
hash
=
detection
content
=
CharlockHolmes
::
Converter
.
convert
(
content
,
hash
[
:encoding
],
'UTF-8'
)
if
hash
[
:encoding
]
hash
=
CharlockHolmes
::
EncodingDetector
.
detect
(
content
)
if
hash
return
content
if
hash
[
:type
]
==
:binary
if
hash
[
:encoding
]
==
"UTF-8"
content
=
if
hash
[
:confidence
]
<
100
content
else
content
.
force_encoding
(
"UTF-8"
)
end
return
content
end
CharlockHolmes
::
Converter
.
convert
(
content
,
hash
[
:encoding
],
'UTF-8'
)
if
hash
[
:encoding
]
else
content
.
force_encoding
(
"UTF-8"
)
end
end
def
z_binary?
(
string
)
string
.
each_byte
do
|
x
|
x
.
nonzero?
or
return
true
end
content
false
end
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