Skip to content

Commit

Permalink
info: only include proto package names. they are all on buf
Browse files Browse the repository at this point in the history
  • Loading branch information
colindickson committed Sep 21, 2023
1 parent 5266d08 commit 4f5dfb5
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions info/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import (
)

type BasicInfo struct {
Name string `json:"name"`
Version string `json:"version"`
Documentation *string `json:"documentation,omitempty"`
Modules []ModulesInfo `json:"modules"`
ProtoFiles []ProtoFileInfo `json:"proto_files"`
Name string `json:"name"`
Version string `json:"version"`
Documentation *string `json:"documentation,omitempty"`
Modules []ModulesInfo `json:"modules"`
ProtoPackages []string `json:"proto_packages"`
}

type ExtendedInfo struct {
Expand Down Expand Up @@ -133,20 +133,21 @@ func Basic(manifestPath string) (*BasicInfo, error) {

modules = append(modules, modInfo)
}
manifestInfo.Modules = modules

protoFiles := make([]ProtoFileInfo, 0, len(pkg.ProtoFiles))
protoPackages := make([]string, 0, len(pkg.ProtoFiles))
protoPackageMap := make(map[string]struct{})
for _, protoFile := range pkg.ProtoFiles {
protoFiles = append(protoFiles, ProtoFileInfo{
Name: protoFile.Name,
Package: protoFile.Package,
Dependencies: protoFile.Dependency,
PublicDependencies: protoFile.PublicDependency,
MessageType: protoFile.MessageType,
})
if _, ok := protoPackageMap[protoFile.GetPackage()]; ok {
continue
} else {
protoPackageMap[protoFile.GetPackage()] = struct{}{}
}

protoPackages = append(protoPackages, protoFile.GetPackage())
}

manifestInfo.Modules = modules
manifestInfo.ProtoFiles = protoFiles
manifestInfo.ProtoPackages = protoPackages

return manifestInfo, nil
}
Expand Down

0 comments on commit 4f5dfb5

Please sign in to comment.