diff --git a/CHANGELOG b/CHANGELOG index 5f903092a4c2365dac5ee90fbb5740f49aa5fb41..369cc485f1a5a01016534f023ca2d51700b69893 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,7 +1,5 @@ Please view this file on the master branch, on stable branches it's out of date. -v 8.3.0 (unreleased) - - Merge when build succeeds (Zeger-Jan van de Weg) v 8.4.0 (unreleased) - Autocomplete data is now always loaded, instead of when focusing a comment text area (Yorick Peterse) - Improved performance of finding issues for an entire group (Yorick Peterse) @@ -15,6 +13,7 @@ v 8.4.0 (unreleased) - Fix missing date of month in network graph when commits span a month (Stan Hu) - Expire view caches when application settings change (e.g. Gravatar disabled) (Stan Hu) - Don't notify users twice if they are both project watchers and subscribers (Stan Hu) + - Fix error with file size check with submodules (Stan Hu) - Implement new UI for group page - Implement search inside emoji picker - Add API support for looking up a user by username (Stan Hu) diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index b344ff84503b33eb7c8b7f0d09bc80e85a960f50..b578f0841b870d0307215d47626872e4b1480464 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -257,7 +257,7 @@ def check_commit_diff(commit, git_hook) next if diff.deleted_file blob = project.repository.blob_at(commit.id, diff.new_path) - if blob.size > git_hook.max_file_size.megabytes + if blob && blob.size && blob.size > git_hook.max_file_size.megabytes return build_status_object(false, "File #{diff.new_path.inspect} is larger than the allowed size of #{git_hook.max_file_size} MB") end end diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb index dd16ce4724c3ed2bfad0407bbc885168dcd27111..c462a70230ccb786954968a295e091ae9459b306 100644 --- a/spec/lib/gitlab/git_access_spec.rb +++ b/spec/lib/gitlab/git_access_spec.rb @@ -311,6 +311,13 @@ def self.updated_permissions_matrix project.git_hook.update(max_file_size: 2) expect(access.git_hook_check(user, project, 'refs/heads/master', 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660', '913c66a37b4a45b9769037c55c2d238bd0942d2e')).to be_allowed end + + it "returns true when size is nil" do + allow_any_instance_of(Gitlab::Git::Blob).to receive(:size).and_return(nil) + project.create_git_hook + project.git_hook.update(max_file_size: 2) + expect(access.git_hook_check(user, project, 'refs/heads/master', 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660', '913c66a37b4a45b9769037c55c2d238bd0942d2e')).to be_allowed + end end end end