From bb5a2684de8b53cd23199965bdd193a80168eb44 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Tue, 19 Oct 2021 16:21:24 -0700 Subject: [PATCH] Minor whitespace fixes and test fixups. --- .../protobuf/compiler/ruby/ruby_generated_code_pb.rb | 3 ++- .../compiler/ruby/ruby_generated_code_proto2_pb.rb | 3 ++- src/google/protobuf/compiler/ruby/ruby_generator.cc | 10 ++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/google/protobuf/compiler/ruby/ruby_generated_code_pb.rb b/src/google/protobuf/compiler/ruby/ruby_generated_code_pb.rb index 4cf4866cfa..256ac7c153 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generated_code_pb.rb +++ b/src/google/protobuf/compiler/ruby/ruby_generated_code_pb.rb @@ -1,9 +1,10 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! # source: ruby_generated_code.proto -require 'ruby_generated_code_proto2_import_pb' require 'google/protobuf' +require 'ruby_generated_code_proto2_import_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("ruby_generated_code.proto", :syntax => :proto3) do add_message "A.B.C.TestMessage" do diff --git a/src/google/protobuf/compiler/ruby/ruby_generated_code_proto2_pb.rb b/src/google/protobuf/compiler/ruby/ruby_generated_code_proto2_pb.rb index e331e9b2b3..44d31969ec 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generated_code_proto2_pb.rb +++ b/src/google/protobuf/compiler/ruby/ruby_generated_code_proto2_pb.rb @@ -1,9 +1,10 @@ # Generated by the protocol buffer compiler. DO NOT EDIT! # source: ruby_generated_code_proto2.proto -require 'ruby_generated_code_proto2_import_pb' require 'google/protobuf' +require 'ruby_generated_code_proto2_import_pb' + Google::Protobuf::DescriptorPool.generated_pool.build do add_file("ruby_generated_code_proto2.proto", :syntax => :proto2) do add_message "A.B.C.TestMessage" do diff --git a/src/google/protobuf/compiler/ruby/ruby_generator.cc b/src/google/protobuf/compiler/ruby/ruby_generator.cc index 6f718cfd5a..46e60f5874 100644 --- a/src/google/protobuf/compiler/ruby/ruby_generator.cc +++ b/src/google/protobuf/compiler/ruby/ruby_generator.cc @@ -507,11 +507,13 @@ bool GenerateFile(const FileDescriptor* file, io::Printer* printer, "\n", "filename", file->name()); - printer->Print( - "require 'google/protobuf'\n\n"); + printer->Print("require 'google/protobuf'\n\n"); - for (int i = 0; i < file->dependency_count(); i++) { - printer->Print("require '$name$'\n", "name", GetRequireName(file->dependency(i)->name())); + if (file->dependency_count() != 0) { + for (int i = 0; i < file->dependency_count(); i++) { + printer->Print("require '$name$'\n", "name", GetRequireName(file->dependency(i)->name())); + } + printer->Print("\n"); } // TODO: Remove this when ruby supports extensions for proto2 syntax.