Commit 71033c9e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

handle broken diffs gracefully

parent 86ae7278
...@@ -118,7 +118,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -118,7 +118,7 @@ class MergeRequest < ActiveRecord::Base
end end
def broken_diffs? def broken_diffs?
diffs == [Gitlab::Git::Diff::BROKEN_DIFF] diffs == broken_diffs
end end
def valid_diffs? def valid_diffs?
...@@ -214,10 +214,22 @@ class MergeRequest < ActiveRecord::Base ...@@ -214,10 +214,22 @@ class MergeRequest < ActiveRecord::Base
end end
def dump_diffs(diffs) def dump_diffs(diffs)
if broken_diffs?
broken_diffs
else
diffs.map(&:to_hash) diffs.map(&:to_hash)
end end
end
def load_diffs(raw)
if raw == broken_diffs
broken_diffs
else
raw.map { |hash| Gitlab::Git::Diff.new(hash) }
end
end
def load_diffs(array) def broken_diffs
array.map { |hash| Gitlab::Git::Diff.new(hash) } [Gitlab::Git::Diff::BROKEN_DIFF]
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment