gitlab_git 10.4.2 → 10.4.3

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: e30dbf365616d1882c82f8b7dab9df82a263fbbd
4
- data.tar.gz: 2fa32f9affdc6f0b431b598b463c7c0a8584aa4f
3
+ metadata.gz: 01b37a892f1f38530140a9011553c495ecc33f23
4
+ data.tar.gz: 26cbfd7f959a1f76e54d6244ccbec5c60297c93f
5
5
  SHA512:
6
- metadata.gz: b39cbb770c89b34fc94a9e9758ddc7ef8be5ceb89c6f403c85ba3b883ef9f1ee0ca4ba86b806ffb1b04363716e5941f5ba52cd90428f47ace13de9c043480fe0
7
- data.tar.gz: 987439cb257e6b0dbcfb794f522888ed47ca63a1d7c04c8c5fdff607fd27cad6569e01ecdfef2cabb6de6122861caf8be38a9970bfb4622c74fe646d6a20fdf0
6
+ metadata.gz: ff5d5c4d4ef411f7d99089d874de79f33ab0be52390d70cdfc81feb97054f13bc6923ac26584ab96d9c326e604f924cfb6fc4debd5ddfc6186f462083b9eb3ae
7
+ data.tar.gz: 2cb19139c2a10e5452eaffd3381f25122f656e10da9b8cb5f7e5f5fdb8991e39084c6e3feb1de7f98a5abf07973c5519329a7ea1ae76f70b259ed9f48103d6d4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 10.4.2
1
+ 10.4.3
@@ -159,12 +159,13 @@ module Gitlab
159
159
  end
160
160
 
161
161
  def initialize(raw_diff)
162
- raise "Nil as raw diff passed" unless raw_diff
163
-
164
- if raw_diff.is_a?(Hash)
162
+ case raw_diff
163
+ when Hash
165
164
  init_from_hash(raw_diff)
166
- elsif raw_diff.is_a?(Rugged::Patch)
165
+ when Rugged::Patch, Rugged::Diff::Delta
167
166
  init_from_rugged(raw_diff)
167
+ when nil
168
+ raise "Nil as raw diff passed"
168
169
  else
169
170
  raise "Invalid raw diff type: #{raw_diff.class}"
170
171
  end
@@ -226,9 +227,13 @@ module Gitlab
226
227
  private
227
228
 
228
229
  def init_from_rugged(rugged)
229
- @diff = encode!(strip_diff_headers(rugged.to_s))
230
+ if rugged.is_a?(Rugged::Patch)
231
+ @diff = encode!(strip_diff_headers(rugged.to_s))
232
+ d = rugged.delta
233
+ else
234
+ d = rugged
235
+ end
230
236
 
231
- d = rugged.delta
232
237
  @new_path = encode!(d.new_file[:path])
233
238
  @old_path = encode!(d.old_file[:path])
234
239
  @a_mode = d.old_file[:mode].to_s(8)
@@ -15,6 +15,7 @@ module Gitlab
15
15
  @safe_max_bytes = @safe_max_files * 5120 # Average 5 KB per file
16
16
  @all_diffs = !!options.fetch(:all_diffs, false)
17
17
  @no_collapse = !!options.fetch(:no_collapse, true)
18
+ @deltas_only = !!options.fetch(:deltas_only, false)
18
19
 
19
20
  @line_count = 0
20
21
  @byte_count = 0
@@ -22,59 +23,14 @@ module Gitlab
22
23
  @array = Array.new
23
24
  end
24
25
 
25
- def each
26
+ def each(&block)
26
27
  if @populated
27
28
  # @iterator.each is slower than just iterating the array in place
28
- @array.each do |item|
29
- yield item
30
- end
29
+ @array.each(&block)
30
+ elsif @deltas_only
31
+ each_delta(&block)
31
32
  else
32
- @iterator.each_with_index do |raw, i|
33
- # First yield cached Diff instances from @array
34
- if @array[i]
35
- yield @array[i]
36
- next
37
- end
38
-
39
- # We have exhausted @array, time to create new Diff instances or stop.
40
- break if @overflow
41
-
42
- if !@all_diffs && i >= @max_files
43
- @overflow = true
44
- break
45
- end
46
-
47
- # Going by the number of files alone it is OK to create a new Diff instance.
48
- diff = Gitlab::Git::Diff.new(raw)
49
-
50
- # If a diff is too large we still want to display some information
51
- # about it (e.g. the file path) without keeping the raw data around
52
- # (as this would be a waste of memory usage).
53
- #
54
- # This also removes the line count (from the diff itself) so it
55
- # doesn't add up to the total amount of lines.
56
- if diff.too_large?
57
- diff.prune_large_diff!
58
- end
59
-
60
- if !@all_diffs && !@no_collapse
61
- if diff.collapsible? || over_safe_limits?(i)
62
- diff.prune_collapsed_diff!
63
- end
64
- end
65
-
66
- @line_count += diff.line_count
67
- @byte_count += diff.diff.bytesize
68
-
69
- if !@all_diffs && (@line_count >= @max_lines || @byte_count >= @max_bytes)
70
- # This last Diff instance pushes us over the lines limit. We stop and
71
- # discard it.
72
- @overflow = true
73
- break
74
- end
75
-
76
- yield @array[i] = diff
77
- end
33
+ each_patch(&block)
78
34
  end
79
35
  end
80
36
 
@@ -122,6 +78,63 @@ module Gitlab
122
78
  def over_safe_limits?(files)
123
79
  files >= @safe_max_files || @line_count > @safe_max_lines || @byte_count >= @safe_max_bytes
124
80
  end
81
+
82
+ def each_delta
83
+ @iterator.each_delta.with_index do |delta, i|
84
+ diff = Gitlab::Git::Diff.new(delta)
85
+
86
+ yield @array[i] = diff
87
+ end
88
+ end
89
+
90
+ def each_patch
91
+ @iterator.each_with_index do |raw, i|
92
+ # First yield cached Diff instances from @array
93
+ if @array[i]
94
+ yield @array[i]
95
+ next
96
+ end
97
+
98
+ # We have exhausted @array, time to create new Diff instances or stop.
99
+ break if @overflow
100
+
101
+ if !@all_diffs && i >= @max_files
102
+ @overflow = true
103
+ break
104
+ end
105
+
106
+ # Going by the number of files alone it is OK to create a new Diff instance.
107
+ diff = Gitlab::Git::Diff.new(raw)
108
+
109
+ # If a diff is too large we still want to display some information
110
+ # about it (e.g. the file path) without keeping the raw data around
111
+ # (as this would be a waste of memory usage).
112
+ #
113
+ # This also removes the line count (from the diff itself) so it
114
+ # doesn't add up to the total amount of lines.
115
+ if diff.too_large?
116
+ diff.prune_large_diff!
117
+ end
118
+
119
+ if !@all_diffs && !@no_collapse
120
+ if diff.collapsible? || over_safe_limits?(i)
121
+ diff.prune_collapsed_diff!
122
+ end
123
+ end
124
+
125
+ @line_count += diff.line_count
126
+ @byte_count += diff.diff.bytesize
127
+
128
+ if !@all_diffs && (@line_count >= @max_lines || @byte_count >= @max_bytes)
129
+ # This last Diff instance pushes us over the lines limit. We stop and
130
+ # discard it.
131
+ @overflow = true
132
+ break
133
+ end
134
+
135
+ yield @array[i] = diff
136
+ end
137
+ end
125
138
  end
126
139
  end
127
140
  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: 10.4.2
4
+ version: 10.4.3
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-07-29 00:00:00.000000000 Z
11
+ date: 2016-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: github-linguist
@@ -125,9 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  requirements: []
127
127
  rubyforge_project:
128
- rubygems_version: 2.5.1
128
+ rubygems_version: 2.2.5
129
129
  signing_key:
130
130
  specification_version: 4
131
131
  summary: Gitlab::Git library
132
132
  test_files: []
133
- has_rdoc: