protogen: avoid an obscure package name consistency check failure
When performing consistency checks on package names, ignore files that
are mentioned on the command line (M<filename>=<import_path>) but which
do not appear in the CodeGeneratorRequest.
Change-Id: I51f1eeda5eaaac14f4a0a975163f65d7774e7212
Reviewed-on: https://go-review.googlesource.com/c/140717
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/protogen/protogen.go b/protogen/protogen.go
index 4e76c30..0ad5420 100644
--- a/protogen/protogen.go
+++ b/protogen/protogen.go
@@ -275,6 +275,11 @@
// the same Go package name.
packageFiles := make(map[GoImportPath][]string)
for filename, importPath := range importPaths {
+ if _, ok := packageNames[filename]; !ok {
+ // Skip files mentioned in a M<file>=<import_path> parameter
+ // but which do not appear in the CodeGeneratorRequest.
+ continue
+ }
packageFiles[importPath] = append(packageFiles[importPath], filename)
}
for importPath, filenames := range packageFiles {