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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
dbaed90c
Commit
dbaed90c
authored
Sep 04, 2017
by
micael.bergeron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix refactoring error with Blob.binary?
remove some lint
parent
5625b0e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
lib/gitlab/encoding_helper.rb
lib/gitlab/encoding_helper.rb
+4
-4
lib/gitlab/git/blob.rb
lib/gitlab/git/blob.rb
+4
-4
lib/gitlab/git/diff.rb
lib/gitlab/git/diff.rb
+2
-2
No files found.
lib/gitlab/encoding_helper.rb
View file @
dbaed90c
...
@@ -14,7 +14,7 @@ module Gitlab
...
@@ -14,7 +14,7 @@ module Gitlab
ENCODING_CONFIDENCE_THRESHOLD
=
50
ENCODING_CONFIDENCE_THRESHOLD
=
50
#
#
#
#
def
encode!
(
message
)
def
encode!
(
message
)
return
nil
unless
message
.
respond_to?
:force_encoding
return
nil
unless
message
.
respond_to?
:force_encoding
...
@@ -33,12 +33,12 @@ module Gitlab
...
@@ -33,12 +33,12 @@ module Gitlab
# encode and clean the bad chars
# encode and clean the bad chars
message
.
replace
clean
(
message
)
message
.
replace
clean
(
message
)
rescue
=>
e
rescue
encoding
=
detect
?
detect
[
:encoding
]
:
"unknown"
encoding
=
detect
?
detect
[
:encoding
]
:
"unknown"
"--broken encoding:
#{
encoding
}
"
"--broken encoding:
#{
encoding
}
"
end
end
def
all_binary?
(
data
,
detect
=
nil
)
def
all_binary?
(
data
,
detect
=
nil
)
detect
||=
CharlockHolmes
::
EncodingDetector
.
detect
(
data
)
detect
||=
CharlockHolmes
::
EncodingDetector
.
detect
(
data
)
detect
&&
detect
[
:type
]
==
:binary
detect
&&
detect
[
:type
]
==
:binary
end
end
...
@@ -65,7 +65,7 @@ module Gitlab
...
@@ -65,7 +65,7 @@ module Gitlab
clean
(
message
)
clean
(
message
)
end
end
end
end
private
private
def
clean
(
message
)
def
clean
(
message
)
...
...
lib/gitlab/git/blob.rb
View file @
dbaed90c
...
@@ -57,6 +57,10 @@ module Gitlab
...
@@ -57,6 +57,10 @@ module Gitlab
end
end
end
end
def
binary?
(
data
)
EncodingHelper
.
libgit2_binary?
(
data
)
end
private
private
# Recursive search of blob id by path
# Recursive search of blob id by path
...
@@ -161,10 +165,6 @@ module Gitlab
...
@@ -161,10 +165,6 @@ module Gitlab
end
end
end
end
end
end
def
binary?
(
data
)
EncodingHelper
.
libgit2_binary?
(
data
)
end
end
end
def
initialize
(
options
)
def
initialize
(
options
)
...
...
lib/gitlab/git/diff.rb
View file @
dbaed90c
...
@@ -118,7 +118,7 @@ module Gitlab
...
@@ -118,7 +118,7 @@ module Gitlab
end
end
# Return a binary diff message like:
# Return a binary diff message like:
#
#
# "Binary files a/file/path and b/file/path differ\n"
# "Binary files a/file/path and b/file/path differ\n"
def
binary_message
(
old_path
,
new_path
)
def
binary_message
(
old_path
,
new_path
)
"Binary files
#{
old_path
}
and
#{
new_path
}
differ
\n
"
"Binary files
#{
old_path
}
and
#{
new_path
}
differ
\n
"
...
@@ -201,7 +201,7 @@ module Gitlab
...
@@ -201,7 +201,7 @@ module Gitlab
return
@diff
unless
all_binary?
(
@diff
)
return
@diff
unless
all_binary?
(
@diff
)
# the diff is binary, let's make a message for it
# the diff is binary, let's make a message for it
Diff
::
binary_message
(
@old_path
,
@new_path
)
Diff
.
binary_message
(
@old_path
,
@new_path
)
end
end
private
private
...
...
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