mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 18:51:59 +00:00
grpc: gitserver: use generated getters to access fields for BatchLog (#54194)
Using the generated getters protects against the request itself being nil (which is possible since all fields are optional in protobuf 3). ## Test plan Unit tests
This commit is contained in:
parent
b561cc3b1b
commit
14ae91ece7
@ -33,18 +33,19 @@ type GRPCServer struct {
|
||||
func (gs *GRPCServer) BatchLog(ctx context.Context, req *proto.BatchLogRequest) (*proto.BatchLogResponse, error) {
|
||||
gs.Server.operations = gs.Server.ensureOperations()
|
||||
|
||||
var internalReq protocol.BatchLogRequest
|
||||
internalReq.FromProto(req)
|
||||
// Validate request parameters
|
||||
if len(req.RepoCommits) == 0 {
|
||||
if len(req.GetRepoCommits()) == 0 {
|
||||
return &proto.BatchLogResponse{}, nil
|
||||
}
|
||||
if !strings.HasPrefix(req.Format, "--format=") {
|
||||
if !strings.HasPrefix(req.GetFormat(), "--format=") {
|
||||
return nil, status.Error(codes.InvalidArgument, "format parameter expected to be of the form `--format=<git log format>`")
|
||||
}
|
||||
|
||||
var r protocol.BatchLogRequest
|
||||
r.FromProto(req)
|
||||
|
||||
// Handle unexpected error conditions
|
||||
resp, err := gs.Server.batchGitLogInstrumentedHandler(ctx, internalReq)
|
||||
resp, err := gs.Server.batchGitLogInstrumentedHandler(ctx, r)
|
||||
if err != nil {
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user