gitlab_git 5.1.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f27529cfedcde0463fd58df616dd0ccfc0f8d747
4
- data.tar.gz: d9b76853f6e0ab13439e56fd8cc4c67c8d3b75ee
3
+ metadata.gz: 68bd2b8cece23ce9a6c60c5303bb084ffc2bdeb4
4
+ data.tar.gz: dd31b1e48b9bcb854c3405025299f0799185d309
5
5
  SHA512:
6
- metadata.gz: bce2de00ee1416fd9fe88d3d8987df62f046ef0c4443df8e3c1a64a24d93ca194706bb4795635ff86e4d01ab5b3087954ee00ac480b0613e33099c92ab8f10b5
7
- data.tar.gz: b0c00d55181cb8bd403322bae01bd5f73d73578a9cac7a1b110b81997ff85d81f95f5ed4ea3932519a07ad3f35510118a3b089608e559873a4337ea41e85137e
6
+ metadata.gz: 068c5c67a558a81f61af31b35e2a9534c633a9b28c2ff2d60e9823909ed2a2fe176d298c5a1bf23969345410a1f20b2b23c388d659c3f197677533974da786a1
7
+ data.tar.gz: fc020e342e8df55bb3ca3458b92e6f7a56b332862e17f6600b9a5ec82fa93d1afbf491a8fec7f38867218981c3ea18709d110c109e4ed78ad69fce6d1466fa0d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 5.1.0
1
+ 5.2.0
data/lib/gitlab_git.rb CHANGED
@@ -7,6 +7,7 @@ require 'active_support/core_ext/hash/keys'
7
7
  require 'grit'
8
8
  require 'grit_ext'
9
9
  require 'rugged'
10
+ require "charlock_holmes"
10
11
 
11
12
  Grit::Blob.class_eval do
12
13
  include Linguist::BlobHelper
@@ -14,6 +15,7 @@ end
14
15
 
15
16
  # Gitlab::Git
16
17
  require_relative "gitlab_git/popen"
18
+ require_relative "gitlab_git/encoding_herlper"
17
19
  require_relative "gitlab_git/blame"
18
20
  require_relative "gitlab_git/blob"
19
21
  require_relative "gitlab_git/commit"
@@ -2,6 +2,7 @@ module Gitlab
2
2
  module Git
3
3
  class Blob
4
4
  include Linguist::BlobHelper
5
+ include EncodingHelper
5
6
 
6
7
  attr_accessor :name, :path, :size, :data, :mode, :id, :commit_id
7
8
 
@@ -84,6 +85,14 @@ module Gitlab
84
85
  def empty?
85
86
  !data || data == ''
86
87
  end
88
+
89
+ def data
90
+ encode! @data
91
+ end
92
+
93
+ def name
94
+ encode! @name
95
+ end
87
96
  end
88
97
  end
89
98
  end
@@ -0,0 +1,34 @@
1
+ module EncodingHelper
2
+ extend self
3
+
4
+ def encode!(message)
5
+ return nil unless message.respond_to? :force_encoding
6
+
7
+ # if message is utf-8 encoding, just return it
8
+ message.force_encoding("UTF-8")
9
+ return message if message.valid_encoding?
10
+
11
+ # return message if message type is binary
12
+ detect = CharlockHolmes::EncodingDetector.detect(message)
13
+ return message.force_encoding("BINARY") if detect && detect[:type] == :binary
14
+
15
+ # encoding message to detect encoding
16
+ if detect && detect[:encoding]
17
+ message.force_encoding(detect[:encoding])
18
+ end
19
+
20
+ # encode and clean the bad chars
21
+ message.replace clean(message)
22
+ rescue
23
+ encoding = detect ? detect[:encoding] : "unknown"
24
+ "--broken encoding: #{encoding}"
25
+ end
26
+
27
+ private
28
+
29
+ def clean(message)
30
+ message.encode("UTF-16BE", :undef => :replace, :invalid => :replace, :replace => "")
31
+ .encode("UTF-8")
32
+ .gsub("\0".encode("UTF-8"), "")
33
+ end
34
+ end
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: 5.1.0
4
+ version: 5.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitriy Zaporozhets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-05 00:00:00.000000000 Z
11
+ date: 2014-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab-linguist
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.19.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: charlock_holmes
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.6.9
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.6.9
69
83
  description: GitLab wrapper around git objects
70
84
  email: dmitriy.zaporozhets@gmail.com
71
85
  executables: []
@@ -80,6 +94,7 @@ files:
80
94
  - lib/gitlab_git/commit.rb
81
95
  - lib/gitlab_git/compare.rb
82
96
  - lib/gitlab_git/diff.rb
97
+ - lib/gitlab_git/encoding_herlper.rb
83
98
  - lib/gitlab_git/git_stats.rb
84
99
  - lib/gitlab_git/log_parser.rb
85
100
  - lib/gitlab_git/popen.rb