Commit 7998a3b3 authored by Peter Leitzen's avatar Peter Leitzen

Merge branch 'fix_nil_class_for_bytesize_error' into 'master'

Fix undefined error in Gitlab::Git::Diff

See merge request gitlab-org/gitlab!32967
parents e326c9f8 ff128f93
---
title: Fix undefined error in Gitlab::Git::Diff
merge_request: 32967
author:
type: fixed
......@@ -225,7 +225,7 @@ module Gitlab
end
def init_from_gitaly(diff)
@diff = encode!(diff.patch) if diff.respond_to?(:patch)
@diff = diff.respond_to?(:patch) ? encode!(diff.patch) : ''
@new_path = encode!(diff.to_path.dup)
@old_path = encode!(diff.from_path.dup)
@a_mode = diff.old_mode.to_s(8)
......
......@@ -122,6 +122,36 @@ EOT
end
end
end
context 'using a Gitaly::CommitDelta' do
let(:commit_delta) do
Gitaly::CommitDelta.new(
to_path: ".gitmodules",
from_path: ".gitmodules",
old_mode: 0100644,
new_mode: 0100644,
from_id: '357406f3075a57708d0163752905cc1576fceacc',
to_id: '8e5177d718c561d36efde08bad36b43687ee6bf0'
)
end
let(:diff) { described_class.new(commit_delta) }
it 'initializes the diff' do
expect(diff.to_hash).to eq(@raw_diff_hash.merge(diff: ''))
end
it 'is not too large' do
expect(diff).not_to be_too_large
end
it 'has an empty diff' do
expect(diff.diff).to be_empty
end
it 'is not a binary' do
expect(diff).not_to have_binary_notice
end
end
end
describe 'straight diffs' do
......
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