Commit 408c5952 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'sh-blob-raw-check' into 'master'

Ensure that Blob.raw returns always returns a valid blob object

See merge request gitlab-org/gitlab-ce!14412
parents 41068df7 794b4c55
...@@ -32,6 +32,8 @@ module Gitlab ...@@ -32,6 +32,8 @@ module Gitlab
else else
blob = repository.lookup(sha) blob = repository.lookup(sha)
next unless blob.is_a?(Rugged::Blob)
new( new(
id: blob.oid, id: blob.oid,
size: blob.size, size: blob.size,
......
...@@ -119,10 +119,13 @@ describe Gitlab::Git::Blob, seed_helper: true do ...@@ -119,10 +119,13 @@ describe Gitlab::Git::Blob, seed_helper: true do
shared_examples 'finding blobs by ID' do shared_examples 'finding blobs by ID' do
let(:raw_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::RubyBlob::ID) } let(:raw_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::RubyBlob::ID) }
let(:bad_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::BigCommit::ID) }
it { expect(raw_blob.id).to eq(SeedRepo::RubyBlob::ID) } it { expect(raw_blob.id).to eq(SeedRepo::RubyBlob::ID) }
it { expect(raw_blob.data[0..10]).to eq("require \'fi") } it { expect(raw_blob.data[0..10]).to eq("require \'fi") }
it { expect(raw_blob.size).to eq(669) } it { expect(raw_blob.size).to eq(669) }
it { expect(raw_blob.truncated?).to be_falsey } it { expect(raw_blob.truncated?).to be_falsey }
it { expect(bad_blob).to be_nil }
context 'large file' do context 'large file' do
it 'limits the size of a large file' do it 'limits the size of a large file' 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