Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where txtpb was not properly recognized #2361

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## [Unreleased]

- No changes yet.
- Fix issue where `buf build -o` did not properly output files with the `.txtpb`
extension in Protobuf text format.

## [v1.26.0] - 2023-08-09

Expand Down
8 changes: 4 additions & 4 deletions private/buf/bufconvert/bufconvert.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const (
MessageEncodingBinpb MessageEncoding = iota + 1
// MessageEncodingJSON is the JSON image encoding.
MessageEncodingJSON
// MessageEncodingTextpb is the protobuf text image encoding.
MessageEncodingTextpb
// MessageEncodingTxtpb is the protobuf text image encoding.
MessageEncodingTxtpb
// formatBinpb is the binary format.
formatBinpb = "binpb"
// formatJSON is the JSON format.
Expand Down Expand Up @@ -118,7 +118,7 @@ func parseMessageEncodingExt(ext string, defaultEncoding MessageEncoding) Messag
case formatJSON:
return MessageEncodingJSON
case formatTxtpb:
return MessageEncodingTextpb
return MessageEncodingTxtpb
default:
return defaultEncoding
}
Expand All @@ -131,7 +131,7 @@ func parseMessageEncodingFormat(format string) (MessageEncoding, error) {
case formatJSON:
return MessageEncodingJSON, nil
case formatTxtpb:
return MessageEncodingTextpb, nil
return MessageEncodingTxtpb, nil
default:
return 0, fmt.Errorf("invalid format for message: %q", format)
}
Expand Down
6 changes: 3 additions & 3 deletions private/buf/buffetch/ref_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ func processRawRefImage(rawRef *internal.RawRef) error {
format = formatBinpb
case ".json":
format = formatJSON
case ".textpb":
case ".txtpb":
format = formatTxtpb
case ".gz":
compressionType = internal.CompressionTypeGzip
Expand All @@ -537,7 +537,7 @@ func processRawRefImage(rawRef *internal.RawRef) error {
format = formatBinpb
case ".json":
format = formatJSON
case ".textpb":
case ".txtpb":
format = formatTxtpb
default:
return fmt.Errorf("path %q had .gz extension with unknown format", rawRef.Path)
Expand All @@ -549,7 +549,7 @@ func processRawRefImage(rawRef *internal.RawRef) error {
format = formatBinpb
case ".json":
format = formatJSON
case ".textpb":
case ".txtpb":
format = formatTxtpb
default:
return fmt.Errorf("path %q had .zst extension with unknown format", rawRef.Path)
Expand Down
2 changes: 1 addition & 1 deletion private/buf/bufwire/proto_encoding_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (p *protoEncodingReader) GetMessage(
unmarshaler = protoencoding.NewWireUnmarshaler(resolver)
case bufconvert.MessageEncodingJSON:
unmarshaler = protoencoding.NewJSONUnmarshaler(resolver)
case bufconvert.MessageEncodingTextpb:
case bufconvert.MessageEncodingTxtpb:
unmarshaler = protoencoding.NewTxtpbUnmarshaler(resolver)
default:
return nil, errors.New("unknown message encoding type")
Expand Down
2 changes: 1 addition & 1 deletion private/buf/bufwire/proto_encoding_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (p *protoEncodingWriter) PutMessage(
marshaler = protoencoding.NewWireMarshaler()
case bufconvert.MessageEncodingJSON:
marshaler = protoencoding.NewJSONMarshaler(resolver)
case bufconvert.MessageEncodingTextpb:
case bufconvert.MessageEncodingTxtpb:
marshaler = protoencoding.NewTxtpbMarshaler(resolver)
default:
return errors.New("unknown message encoding type")
Expand Down
2 changes: 1 addition & 1 deletion private/buf/cmd/buf/command/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func inverseEncoding(encoding bufconvert.MessageEncoding) (bufconvert.MessageEnc
return bufconvert.MessageEncodingJSON, nil
case bufconvert.MessageEncodingJSON:
return bufconvert.MessageEncodingBinpb, nil
case bufconvert.MessageEncodingTextpb:
case bufconvert.MessageEncodingTxtpb:
return bufconvert.MessageEncodingBinpb, nil
default:
return 0, fmt.Errorf("unknown message encoding %v", encoding)
Expand Down