gitlab_git 10.0.0 → 10.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/gitlab_git/encoding_helper.rb +13 -2
- data/lib/gitlab_git/repository.rb +10 -0
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2d857c8e1f6c851a7fa699ef3279d936c999c27
|
4
|
+
data.tar.gz: ec384017aa519ce625cc9b05f13725450dd2dabb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38cba0dc0b5db525ac2967133ed0ec439f41d10d153e3dc5608e6d796a4c955d173db00b63e2907e0fcc5620eaeedbef2dabd48a29af506c06090c54b22c9001
|
7
|
+
data.tar.gz: 9aff7f02f2ccf1cf4df3ca23c31ae5b55de7ef204c82ec075087420f7cdeae7924f4d88b89c19a10433fa69339557620e67cb42305b76dec2efb2e8eff49ae5e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
10.0.
|
1
|
+
10.0.1
|
@@ -1,6 +1,17 @@
|
|
1
1
|
module EncodingHelper
|
2
2
|
extend self
|
3
3
|
|
4
|
+
# This threshold is carefully tweaked to prevent usage of encodings detected
|
5
|
+
# by CharlockHolmes with low confidence. If CharlockHolmes confidence is low,
|
6
|
+
# we're better off sticking with utf8 encoding.
|
7
|
+
# Reason: git diff can return strings with invalid utf8 byte sequences if it
|
8
|
+
# truncates a diff in the middle of a multibyte character. In this case
|
9
|
+
# CharlockHolmes will try to guess the encoding and will likely suggest an
|
10
|
+
# obscure encoding with low confidence.
|
11
|
+
# There is a lot more info with this merge request:
|
12
|
+
# https://gitlab.com/gitlab-org/gitlab_git/merge_requests/77#note_4754193
|
13
|
+
ENCODING_CONFIDENCE_THRESHOLD = 40
|
14
|
+
|
4
15
|
def encode!(message)
|
5
16
|
return nil unless message.respond_to? :force_encoding
|
6
17
|
|
@@ -12,8 +23,8 @@ module EncodingHelper
|
|
12
23
|
detect = CharlockHolmes::EncodingDetector.detect(message)
|
13
24
|
return message.force_encoding("BINARY") if detect && detect[:type] == :binary
|
14
25
|
|
15
|
-
# encoding
|
16
|
-
if detect && detect[:encoding]
|
26
|
+
# force detected encoding if we have sufficient confidence.
|
27
|
+
if detect && detect[:encoding] && detect[:confidence] > ENCODING_CONFIDENCE_THRESHOLD
|
17
28
|
message.force_encoding(detect[:encoding])
|
18
29
|
end
|
19
30
|
|
@@ -7,6 +7,7 @@ require "rubygems/package"
|
|
7
7
|
module Gitlab
|
8
8
|
module Git
|
9
9
|
class Repository
|
10
|
+
extend Forwardable
|
10
11
|
include Gitlab::Git::Popen
|
11
12
|
|
12
13
|
SEARCH_CONTEXT_LINES = 3
|
@@ -24,6 +25,9 @@ module Gitlab
|
|
24
25
|
# Rugged repo object
|
25
26
|
attr_reader :rugged
|
26
27
|
|
28
|
+
# Define a delegator for the rugged attributes
|
29
|
+
def_delegator :rugged, :attributes
|
30
|
+
|
27
31
|
# 'path' must be the path to a _bare_ git repository, e.g.
|
28
32
|
# /path/to/my-repo.git
|
29
33
|
def initialize(path)
|
@@ -948,6 +952,12 @@ module Gitlab
|
|
948
952
|
File.write(info_attributes_path, gitattributes_content)
|
949
953
|
end
|
950
954
|
|
955
|
+
# Checks if the blob should be diffable according to its attributes
|
956
|
+
def diffable?(blob)
|
957
|
+
blob_attributes = attributes(blob.path).to_h
|
958
|
+
blob_attributes.fetch('diff', blob.text?)
|
959
|
+
end
|
960
|
+
|
951
961
|
private
|
952
962
|
|
953
963
|
# Get the content of a blob for a given commit. If the blob is a commit
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab_git
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.0.
|
4
|
+
version: 10.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitriy Zaporozhets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: github-linguist
|
@@ -111,9 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
version: '0'
|
112
112
|
requirements: []
|
113
113
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.4.8
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Gitlab::Git library
|
118
118
|
test_files: []
|
119
|
-
has_rdoc:
|