diff --git a/api_proto.go b/api_proto.go index 52dec1952..a6645026d 100644 --- a/api_proto.go +++ b/api_proto.go @@ -37,7 +37,7 @@ func FileMatchFromProto(p *proto.FileMatch) FileMatch { return FileMatch{ Score: p.GetScore(), Debug: p.GetDebug(), - FileName: p.GetFileName(), + FileName: string(p.GetFileName()), // Note: 🚨Warning, this filename may be a non-UTF8 string. Repository: p.GetRepository(), Branches: p.GetBranches(), LineMatches: lineMatches, @@ -67,7 +67,7 @@ func (m *FileMatch) ToProto() *proto.FileMatch { return &proto.FileMatch{ Score: m.Score, Debug: m.Debug, - FileName: m.FileName, + FileName: []byte(m.FileName), Repository: m.Repository, Branches: m.Branches, LineMatches: lineMatches, diff --git a/gen-proto.sh b/gen-proto.sh new file mode 100755 index 000000000..cc2e29341 --- /dev/null +++ b/gen-proto.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +cd "$(dirname "${BASH_SOURCE[0]}")" +set -euo pipefail + +find . -name "buf.gen.yaml" -not -path ".git" | while read -r buf_yaml; do + pushd "$(dirname "${buf_yaml}")" >/dev/null + buf generate + popd >/dev/null +done diff --git a/grpc/v1/webserver.pb.go b/grpc/v1/webserver.pb.go index 027806286..759241b5e 100644 --- a/grpc/v1/webserver.pb.go +++ b/grpc/v1/webserver.pb.go @@ -1558,8 +1558,10 @@ type FileMatch struct { Score float64 `protobuf:"fixed64,1,opt,name=score,proto3" json:"score,omitempty"` // For debugging. Needs DebugScore set, but public so tests in // other packages can print some diagnostics. - Debug string `protobuf:"bytes,2,opt,name=debug,proto3" json:"debug,omitempty"` - FileName string `protobuf:"bytes,3,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` + Debug string `protobuf:"bytes,2,opt,name=debug,proto3" json:"debug,omitempty"` + // The repository-relative path to the file. + // 🚨 Warning: file_name might not be a valid UTF-8 string. + FileName []byte `protobuf:"bytes,3,opt,name=file_name,json=fileName,proto3" json:"file_name,omitempty"` // Repository is the globally unique name of the repo of the // match Repository string `protobuf:"bytes,4,opt,name=repository,proto3" json:"repository,omitempty"` @@ -1634,11 +1636,11 @@ func (x *FileMatch) GetDebug() string { return "" } -func (x *FileMatch) GetFileName() string { +func (x *FileMatch) GetFileName() []byte { if x != nil { return x.FileName } - return "" + return nil } func (x *FileMatch) GetRepository() string { @@ -2539,7 +2541,7 @@ var file_webserver_proto_rawDesc = []byte{ 0x18, 0x01, 0x20, 0x01, 0x28, 0x01, 0x52, 0x05, 0x73, 0x63, 0x6f, 0x72, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x64, 0x65, 0x62, 0x75, 0x67, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, + 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x08, 0x66, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f, 0x72, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x65, 0x73, 0x18, 0x05, 0x20, 0x03, diff --git a/grpc/v1/webserver.proto b/grpc/v1/webserver.proto index 8667bdc0b..0fc50bc8e 100644 --- a/grpc/v1/webserver.proto +++ b/grpc/v1/webserver.proto @@ -380,7 +380,9 @@ message FileMatch { // other packages can print some diagnostics. string debug = 2; - string file_name = 3; + // The repository-relative path to the file. + // 🚨 Warning: file_name might not be a valid UTF-8 string. + bytes file_name = 3; // Repository is the globally unique name of the repo of the // match