Skip to content

Commit

Permalink
grpc: FileMatch: tweak file_name to be bytes instead of string (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
ggilmore authored Aug 25, 2023
1 parent f75df3d commit 40a9a23
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions api_proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions gen-proto.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 7 additions & 5 deletions grpc/v1/webserver.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion grpc/v1/webserver.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 40a9a23

Please sign in to comment.