Commit 71033c9efb9dc1e9cb28b01b2b5aa55a50d2c8d7
1 parent
86ae7278
Exists in
master
and in
4 other branches
handle broken diffs gracefully
Showing
1 changed file
with
16 additions
and
4 deletions
Show diff stats
app/models/merge_request.rb
| @@ -118,7 +118,7 @@ class MergeRequest < ActiveRecord::Base | @@ -118,7 +118,7 @@ class MergeRequest < ActiveRecord::Base | ||
| 118 | end | 118 | end |
| 119 | 119 | ||
| 120 | def broken_diffs? | 120 | def broken_diffs? |
| 121 | - diffs == [Gitlab::Git::Diff::BROKEN_DIFF] | 121 | + diffs == broken_diffs |
| 122 | end | 122 | end |
| 123 | 123 | ||
| 124 | def valid_diffs? | 124 | def valid_diffs? |
| @@ -214,10 +214,22 @@ class MergeRequest < ActiveRecord::Base | @@ -214,10 +214,22 @@ class MergeRequest < ActiveRecord::Base | ||
| 214 | end | 214 | end |
| 215 | 215 | ||
| 216 | def dump_diffs(diffs) | 216 | def dump_diffs(diffs) |
| 217 | - diffs.map(&:to_hash) | 217 | + if broken_diffs? |
| 218 | + broken_diffs | ||
| 219 | + else | ||
| 220 | + diffs.map(&:to_hash) | ||
| 221 | + end | ||
| 222 | + end | ||
| 223 | + | ||
| 224 | + def load_diffs(raw) | ||
| 225 | + if raw == broken_diffs | ||
| 226 | + broken_diffs | ||
| 227 | + else | ||
| 228 | + raw.map { |hash| Gitlab::Git::Diff.new(hash) } | ||
| 229 | + end | ||
| 218 | end | 230 | end |
| 219 | 231 | ||
| 220 | - def load_diffs(array) | ||
| 221 | - array.map { |hash| Gitlab::Git::Diff.new(hash) } | 232 | + def broken_diffs |
| 233 | + [Gitlab::Git::Diff::BROKEN_DIFF] | ||
| 222 | end | 234 | end |
| 223 | end | 235 | end |