Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
awalterschulze committed Aug 24, 2016
2 parents 909568b + c641daa commit 6b3c801
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion protoc-gen-gogofast/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
func main() {
req := command.Read()
files := req.GetProtoFile()
files = vanity.FilterFiles(files, vanity.NotInPackageGoogleProtobuf)
files = vanity.FilterFiles(files, vanity.NotGoogleProtobufDescriptorProto)

vanity.ForEachFile(files, vanity.TurnOnMarshalerAll)
vanity.ForEachFile(files, vanity.TurnOnSizerAll)
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-gogofaster/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
func main() {
req := command.Read()
files := req.GetProtoFile()
files = vanity.FilterFiles(files, vanity.NotInPackageGoogleProtobuf)
files = vanity.FilterFiles(files, vanity.NotGoogleProtobufDescriptorProto)

vanity.ForEachFile(files, vanity.TurnOnMarshalerAll)
vanity.ForEachFile(files, vanity.TurnOnSizerAll)
Expand Down
2 changes: 1 addition & 1 deletion protoc-gen-gogoslick/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
func main() {
req := command.Read()
files := req.GetProtoFile()
files = vanity.FilterFiles(files, vanity.NotInPackageGoogleProtobuf)
files = vanity.FilterFiles(files, vanity.NotGoogleProtobufDescriptorProto)

vanity.ForEachFile(files, vanity.TurnOnMarshalerAll)
vanity.ForEachFile(files, vanity.TurnOnSizerAll)
Expand Down
8 changes: 5 additions & 3 deletions vanity/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@
package vanity

import (
"strings"
"path/filepath"

"github.com/gogo/protobuf/gogoproto"
"github.com/gogo/protobuf/proto"
descriptor "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
)

func NotInPackageGoogleProtobuf(file *descriptor.FileDescriptorProto) bool {
return !strings.HasPrefix(file.GetPackage(), "google.protobuf")
func NotGoogleProtobufDescriptorProto(file *descriptor.FileDescriptorProto) bool {
// can not just check if file.GetName() == "google/protobuf/descriptor.proto" because we do not want to assume compile path
_, fileName := filepath.Split(file.GetName())
return !(file.GetPackage() == "google.protobuf" && fileName == "descriptor.proto")
}

func FilterFiles(files []*descriptor.FileDescriptorProto, f func(file *descriptor.FileDescriptorProto) bool) []*descriptor.FileDescriptorProto {
Expand Down

0 comments on commit 6b3c801

Please sign in to comment.