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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
b7558a20
Commit
b7558a20
authored
Apr 11, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed encoding monkey patch
parent
52f6df72
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
42 deletions
+43
-42
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+4
-0
app/models/commit.rb
app/models/commit.rb
+4
-3
app/views/commits/_diff_head.html.haml
app/views/commits/_diff_head.html.haml
+9
-9
app/views/commits/_diffs.html.haml
app/views/commits/_diffs.html.haml
+5
-5
config/initializers/gitlabhq/20_grit_ext.rb
config/initializers/gitlabhq/20_grit_ext.rb
+7
-25
lib/gitlabhq/encode.rb
lib/gitlabhq/encode.rb
+14
-0
No files found.
app/helpers/application_helper.rb
View file @
b7558a20
...
@@ -129,4 +129,8 @@ module ApplicationHelper
...
@@ -129,4 +129,8 @@ module ApplicationHelper
"ui_mars"
"ui_mars"
end
end
end
end
def
string_to_utf8
str
Gitlabhq
::
Encode
.
utf8
str
end
end
end
app/models/commit.rb
View file @
b7558a20
class
Commit
class
Commit
include
ActiveModel
::
Conversion
include
ActiveModel
::
Conversion
include
Gitlabhq
::
Encode
extend
ActiveModel
::
Naming
extend
ActiveModel
::
Naming
attr_accessor
:commit
attr_accessor
:commit
...
@@ -90,7 +91,7 @@ class Commit
...
@@ -90,7 +91,7 @@ class Commit
end
end
def
safe_message
def
safe_message
message
utf8
message
end
end
def
created_at
def
created_at
...
@@ -102,11 +103,11 @@ class Commit
...
@@ -102,11 +103,11 @@ class Commit
end
end
def
author_name
def
author_name
author
.
name
.
force_encoding
(
"UTF-8"
)
utf8
author
.
name
end
end
def
committer_name
def
committer_name
committer
.
name
utf8
committer
.
name
end
end
def
committer_email
def
committer_email
...
...
app/views/commits/_diff_head.html.haml
View file @
b7558a20
...
@@ -3,24 +3,24 @@
...
@@ -3,24 +3,24 @@
%li
%li
-
if
diff
.
deleted_file
-
if
diff
.
deleted_file
%span
.removed_file
%span
.removed_file
%a
{
:href
=>
"##{diff.
a
_path}"
}
%a
{
:href
=>
"##{diff.
old
_path}"
}
=
diff
.
a
_path
=
diff
.
old
_path
=
image_tag
"diff_file_delete.png"
=
image_tag
"diff_file_delete.png"
-
elsif
diff
.
renamed_file
-
elsif
diff
.
renamed_file
%span
.moved_file
%span
.moved_file
%a
{
:href
=>
"##{diff.
b
_path}"
}
%a
{
:href
=>
"##{diff.
new
_path}"
}
=
diff
.
a
_path
=
diff
.
old
_path
=
"->"
=
"->"
=
diff
.
b
_path
=
diff
.
new
_path
=
image_tag
"diff_file_notice.png"
=
image_tag
"diff_file_notice.png"
-
elsif
diff
.
new_file
-
elsif
diff
.
new_file
%span
.new_file
%span
.new_file
%a
{
:href
=>
"##{diff.
b
_path}"
}
%a
{
:href
=>
"##{diff.
new
_path}"
}
=
diff
.
b
_path
=
diff
.
new
_path
=
image_tag
"diff_file_add.png"
=
image_tag
"diff_file_add.png"
-
else
-
else
%span
.edit_file
%span
.edit_file
%a
{
:href
=>
"##{diff.
b
_path}"
}
%a
{
:href
=>
"##{diff.
new
_path}"
}
=
diff
.
b
_path
=
diff
.
new
_path
=
image_tag
"diff_file_info.png"
=
image_tag
"diff_file_info.png"
app/views/commits/_diffs.html.haml
View file @
b7558a20
...
@@ -17,16 +17,16 @@
...
@@ -17,16 +17,16 @@
-
unless
@suppress_diff
-
unless
@suppress_diff
-
diffs
.
each_with_index
do
|
diff
,
i
|
-
diffs
.
each_with_index
do
|
diff
,
i
|
-
next
if
diff
.
diff
.
empty?
-
next
if
diff
.
diff
.
empty?
-
file
=
(
@commit
.
tree
/
diff
.
b
_path
)
-
file
=
(
@commit
.
tree
/
diff
.
new
_path
)
-
file
=
(
@commit
.
prev_commit
.
tree
/
diff
.
a
_path
)
unless
file
-
file
=
(
@commit
.
prev_commit
.
tree
/
diff
.
old
_path
)
unless
file
-
next
unless
file
-
next
unless
file
.diff_file
.diff_file
.diff_file_header
.diff_file_header
-
if
diff
.
deleted_file
-
if
diff
.
deleted_file
%strong
{
:id
=>
"#{diff.
a_path}"
}=
diff
.
a
_path
%strong
{
:id
=>
"#{diff.
old_path}"
}=
diff
.
old
_path
-
else
-
else
=
link_to
tree_file_project_ref_path
(
@project
,
@commit
.
id
,
diff
.
b
_path
)
do
=
link_to
tree_file_project_ref_path
(
@project
,
@commit
.
id
,
diff
.
new
_path
)
do
%strong
{
:id
=>
"#{diff.
b_path}"
}=
diff
.
b
_path
%strong
{
:id
=>
"#{diff.
new_path}"
}=
diff
.
new
_path
%br
/
%br
/
.diff_file_content
.diff_file_content
-
if
file
.
text?
-
if
file
.
text?
...
...
config/initializers/gitlabhq/20_grit_ext.rb
View file @
b7558a20
...
@@ -10,38 +10,20 @@ end
...
@@ -10,38 +10,20 @@ end
#monkey patch raw_object from string
#monkey patch raw_object from string
Grit
::
GitRuby
::
Internal
::
RawObject
.
class_eval
do
Grit
::
GitRuby
::
Internal
::
RawObject
.
class_eval
do
def
content
def
content
transcoding
(
@content
)
rescue
Exception
=>
ex
Rails
.
logger
.
error
ex
.
message
@content
@content
end
end
end
private
def
transcoding
(
content
)
content
||=
""
hash
=
CharlockHolmes
::
EncodingDetector
.
detect
(
content
)
if
hash
return
content
if
hash
[
:type
]
==
:binary
if
hash
[
:encoding
]
==
"UTF-8"
Grit
::
Diff
.
class_eval
do
content
=
if
hash
[
:confidence
]
<
100
def
old_path
content
Gitlabhq
::
Encode
.
utf8
a_path
else
content
.
force_encoding
(
"UTF-8"
)
end
end
return
content
def
new_path
end
Gitlabhq
::
Encode
.
utf8
b_path
CharlockHolmes
::
Converter
.
convert
(
content
,
hash
[
:encoding
],
'UTF-8'
)
if
hash
[
:encoding
]
else
content
.
force_encoding
(
"UTF-8"
)
end
end
end
end
end
Grit
::
Git
.
git_timeout
=
GIT_OPTS
[
"git_timeout"
]
Grit
::
Git
.
git_timeout
=
GIT_OPTS
[
"git_timeout"
]
Grit
::
Git
.
git_max_size
=
GIT_OPTS
[
"git_max_size"
]
Grit
::
Git
.
git_max_size
=
GIT_OPTS
[
"git_max_size"
]
lib/gitlabhq/encode.rb
0 → 100644
View file @
b7558a20
module
Gitlabhq
module
Encode
extend
self
def
utf8
message
hash
=
CharlockHolmes
::
EncodingDetector
.
detect
(
message
)
if
hash
[
:encoding
]
CharlockHolmes
::
Converter
.
convert
(
message
,
hash
[
:encoding
],
'UTF-8'
)
else
message
end
.
force_encoding
(
"utf-8"
)
end
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