gitlab_git 10.0.0 → 10.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31c6a37123aa6b3d2a4e5a51508fd0bb46f3fa65
4
- data.tar.gz: 1f9dd6e2548aca96d1b367435e131c78b1c12679
3
+ metadata.gz: a2d857c8e1f6c851a7fa699ef3279d936c999c27
4
+ data.tar.gz: ec384017aa519ce625cc9b05f13725450dd2dabb
5
5
  SHA512:
6
- metadata.gz: 1852e5944d7ec3a02a0c745aa09d381f72cd9233b7bbb92d1ab38582e346ba900b75faea720aa0cdf51c3b8c86e7b1b94c5a8d69e52f105cd1e2ec35de51d7c4
7
- data.tar.gz: 9ea1b801930d276a3de2cbf0ff3ad7e425a333d744c6d18ff34f769d00ff8c4d63a7916feef21632f45a87f2678e3c59c2d1539de79afc7edd64a1c7ccb35441
6
+ metadata.gz: 38cba0dc0b5db525ac2967133ed0ec439f41d10d153e3dc5608e6d796a4c955d173db00b63e2907e0fcc5620eaeedbef2dabd48a29af506c06090c54b22c9001
7
+ data.tar.gz: 9aff7f02f2ccf1cf4df3ca23c31ae5b55de7ef204c82ec075087420f7cdeae7924f4d88b89c19a10433fa69339557620e67cb42305b76dec2efb2e8eff49ae5e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 10.0.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 message to detect 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.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-03-17 00:00:00.000000000 Z
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.5.1
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: