BigW Consortium Gitlab

Commit dbaed90c by micael.bergeron

fix refactoring error with Blob.binary?

remove some lint
parent 5625b0e4
...@@ -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)
......
...@@ -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)
......
...@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment