summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-01-07 01:30:30 -0800
committerStan Hu <stanhu@gmail.com>2018-01-07 01:36:11 -0800
commit9d137f467fbd6c8e64f3347cd8f5dd90ebce729a (patch)
treef61b486efa8bf8d550f4ed3fd4e9f5fde0548dd6
parent54bacb1860036ffcd722f7df033d7def6b1a8756 (diff)
downloadgitlab-ce-sh-fix-issue-41735.tar.gz
Fix error 500 when viewing commit and merge request diffssh-fix-issue-41735
Due to the refactoring in !16082, `Blob#batch` no longer falls back to a default `blob_size_limit`. Since `Repository#batch_blobs` was using a default `nil` value, this would cause issues in the `Blob#find_by_rugged` method. This fix here is to be consistent and use a non-nil default value in `Repository#batch_blobs`. The problem was masked in development and tests because Gitaly is always enabled by default for all features. Closes #41735
-rw-r--r--lib/gitlab/git/repository.rb2
-rw-r--r--spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb14
2 files changed, 15 insertions, 1 deletions
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index 84105501d1e..d7605b74cf1 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -1187,7 +1187,7 @@ module Gitlab
end
# Items should be of format [[commit_id, path], [commit_id1, path1]]
- def batch_blobs(items, blob_size_limit: nil)
+ def batch_blobs(items, blob_size_limit: Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE)
Gitlab::Git::Blob.batch(self, items, blob_size_limit: blob_size_limit)
end
diff --git a/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb b/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
index d81774c8b8f..6fd0267eb10 100644
--- a/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
+++ b/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
@@ -19,4 +19,18 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
diff_files
end
+
+ shared_examples 'initializes a DiffCollection'
+ it 'returns a valid instance of a DiffCollection' do
+ expect(diff_files).to be_a(Gitlab::Git::DiffCollection)
+ end
+ end
+
+ context 'with Gitaly disabled', :disable_gitaly do
+ it_behaves_like 'initializes a DiffCollection'
+ end
+
+ context 'with Gitaly enabled' do
+ it_behaves_like 'initializes a DiffCollection'
+ end
end