Skip to content

Commit

Permalink
fix: emtpy message check
Browse files Browse the repository at this point in the history
Skip conversion in no messages in protofile
  • Loading branch information
mortyshop authored Dec 6, 2022
2 parents 6e07df0 + dc0aa78 commit a7bf7f2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func registerType(pkgName *string, msg *descriptor.DescriptorProto, comments Com
pkg.path[msg.GetName()] = msgPath
}

//nolint: gocritic
// nolint: gocritic
func (protoPkg *ProtoPackage) lookupType(name string) (*descriptor.DescriptorProto, bool, Comments, string) {
if strings.HasPrefix(name, ".") {
return globalPkg.relativelyLookupType(name[1:len(name)])
Expand All @@ -115,7 +115,7 @@ func (protoPkg *ProtoPackage) lookupType(name string) (*descriptor.DescriptorPro
return nil, false, Comments{}, ""
}

//nolint: gocritic
// nolint: gocritic
func relativelyLookupNestedType(desc *descriptor.DescriptorProto, name string) (*descriptor.DescriptorProto, bool, string) {
components := strings.Split(name, ".")
msgPath := ""
Expand All @@ -134,7 +134,7 @@ componentLoop:
return desc, true, strings.Trim(msgPath, ".")
}

//nolint: gocritic
// nolint: gocritic
func (protoPkg *ProtoPackage) relativelyLookupType(name string) (*descriptor.DescriptorProto, bool, Comments, string) {
components := strings.SplitN(name, ".", 2)
switch len(components) {
Expand Down Expand Up @@ -526,6 +526,9 @@ func Convert(req *plugin.CodeGeneratorRequest) (*plugin.CodeGeneratorResponse, e
}
}
for _, file := range req.GetProtoFile() {
if len(file.GetMessageType()) == 0 {
continue
}
if _, ok := generateTargets[file.GetName()]; ok {
glog.V(1).Info("Converting ", file.GetName())
handleSingleMessageOpt(file, req.GetParameter())
Expand Down

0 comments on commit a7bf7f2

Please sign in to comment.