sg lint: fix 'buf lint' rule by actually adding buf.yaml file (#48076)

This commit is contained in:
Geoffrey Gilmore 2023-02-22 15:04:21 -08:00 committed by GitHub
parent 2168eedbed
commit a9ab52aa6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 64 additions and 46 deletions

View File

@ -34,6 +34,10 @@ var bufFormat = &linter{
return errors.Wrapf(err, "finding .proto files")
}
if len(protoFiles) == 0 {
return errors.New("no .proto files found")
}
bufArgs := []string{
"format",
"--diff",
@ -128,6 +132,10 @@ var bufLint = &linter{
return errors.Wrapf(err, "finding buf module files")
}
if len(bufModules) == 0 {
return errors.New("no buf modules found")
}
for _, file := range bufModules {
file, err := filepath.Rel(rootDir, file)
if err != nil {
@ -185,8 +193,7 @@ var bufGenerate = &linter{
}
if len(generatedFiles) == 0 {
// no generated files, nothing to check
return nil
return errors.New("no generated files found")
}
gitArgs := []string{

7
internal/buf.yaml Normal file
View File

@ -0,0 +1,7 @@
version: v1
breaking:
use:
- FILE
lint:
use:
- DEFAULT

View File

@ -7,9 +7,10 @@ import (
"sync"
"time"
"google.golang.org/protobuf/types/known/timestamppb"
proto "github.com/sourcegraph/sourcegraph/internal/gitserver/v1"
"github.com/sourcegraph/sourcegraph/lib/errors"
"google.golang.org/protobuf/types/known/timestamppb"
)
type Node interface {
@ -46,11 +47,11 @@ func NodeFromProto(p *proto.QueryNode) (Node, error) {
}
var kind OperatorKind
switch v.Operator.GetKind() {
case proto.OperatorKind_AND:
case proto.OperatorKind_OPERATOR_KIND_AND:
kind = And
case proto.OperatorKind_OR:
case proto.OperatorKind_OPERATOR_KIND_OR:
kind = Or
case proto.OperatorKind_NOT:
case proto.OperatorKind_OPERATOR_KIND_NOT:
kind = Not
default:
return nil, errors.Newf("unknown operator kind %s", v.Operator.GetKind().String())
@ -239,13 +240,13 @@ const (
func (o OperatorKind) ToProto() proto.OperatorKind {
switch o {
case And:
return proto.OperatorKind_AND
return proto.OperatorKind_OPERATOR_KIND_AND
case Or:
return proto.OperatorKind_OR
return proto.OperatorKind_OPERATOR_KIND_OR
case Not:
return proto.OperatorKind_NOT
return proto.OperatorKind_OPERATOR_KIND_NOT
default:
return proto.OperatorKind_UNSPECIFIED
return proto.OperatorKind_OPERATOR_KIND_UNSPECIFIED
}
}

View File

@ -24,25 +24,25 @@ const (
type OperatorKind int32
const (
OperatorKind_UNSPECIFIED OperatorKind = 0
OperatorKind_AND OperatorKind = 1
OperatorKind_OR OperatorKind = 2
OperatorKind_NOT OperatorKind = 3
OperatorKind_OPERATOR_KIND_UNSPECIFIED OperatorKind = 0
OperatorKind_OPERATOR_KIND_AND OperatorKind = 1
OperatorKind_OPERATOR_KIND_OR OperatorKind = 2
OperatorKind_OPERATOR_KIND_NOT OperatorKind = 3
)
// Enum value maps for OperatorKind.
var (
OperatorKind_name = map[int32]string{
0: "UNSPECIFIED",
1: "AND",
2: "OR",
3: "NOT",
0: "OPERATOR_KIND_UNSPECIFIED",
1: "OPERATOR_KIND_AND",
2: "OPERATOR_KIND_OR",
3: "OPERATOR_KIND_NOT",
}
OperatorKind_value = map[string]int32{
"UNSPECIFIED": 0,
"AND": 1,
"OR": 2,
"NOT": 3,
"OPERATOR_KIND_UNSPECIFIED": 0,
"OPERATOR_KIND_AND": 1,
"OPERATOR_KIND_OR": 2,
"OPERATOR_KIND_NOT": 3,
}
)
@ -958,7 +958,7 @@ func (x *OperatorNode) GetKind() OperatorKind {
if x != nil {
return x.Kind
}
return OperatorKind_UNSPECIFIED
return OperatorKind_OPERATOR_KIND_UNSPECIFIED
}
func (x *OperatorNode) GetOperands() []*QueryNode {
@ -1781,25 +1781,28 @@ var file_gitserver_proto_rawDesc = []byte{
0x28, 0x0d, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6c, 0x69,
0x6e, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x04, 0x6c, 0x69, 0x6e, 0x65, 0x12, 0x16,
0x0a, 0x06, 0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06,
0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x2a, 0x39, 0x0a, 0x0c, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74,
0x6f, 0x72, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x0f, 0x0a, 0x0b, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43,
0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4e, 0x44, 0x10, 0x01,
0x12, 0x06, 0x0a, 0x02, 0x4f, 0x52, 0x10, 0x02, 0x12, 0x07, 0x0a, 0x03, 0x4e, 0x4f, 0x54, 0x10,
0x03, 0x32, 0x9e, 0x01, 0x0a, 0x10, 0x47, 0x69, 0x74, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53,
0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x41, 0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x19,
0x2e, 0x67, 0x69, 0x74, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78,
0x65, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x67, 0x69, 0x74, 0x73,
0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x47, 0x0a, 0x06, 0x53, 0x65, 0x61,
0x72, 0x63, 0x68, 0x12, 0x1b, 0x2e, 0x67, 0x69, 0x74, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e,
0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x1a, 0x1c, 0x2e, 0x67, 0x69, 0x74, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e,
0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x30, 0x01, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2f, 0x73, 0x6f, 0x75,
0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61,
0x6c, 0x2f, 0x67, 0x69, 0x74, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x62, 0x06,
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x63, 0x6f, 0x6c, 0x75, 0x6d, 0x6e, 0x2a, 0x71, 0x0a, 0x0c, 0x4f, 0x70, 0x65, 0x72, 0x61, 0x74,
0x6f, 0x72, 0x4b, 0x69, 0x6e, 0x64, 0x12, 0x1d, 0x0a, 0x19, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54,
0x4f, 0x52, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46,
0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x15, 0x0a, 0x11, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, 0x4f,
0x52, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x41, 0x4e, 0x44, 0x10, 0x01, 0x12, 0x14, 0x0a, 0x10,
0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x4b, 0x49, 0x4e, 0x44, 0x5f, 0x4f, 0x52,
0x10, 0x02, 0x12, 0x15, 0x0a, 0x11, 0x4f, 0x50, 0x45, 0x52, 0x41, 0x54, 0x4f, 0x52, 0x5f, 0x4b,
0x49, 0x4e, 0x44, 0x5f, 0x4e, 0x4f, 0x54, 0x10, 0x03, 0x32, 0x9e, 0x01, 0x0a, 0x10, 0x47, 0x69,
0x74, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x41,
0x0a, 0x04, 0x45, 0x78, 0x65, 0x63, 0x12, 0x19, 0x2e, 0x67, 0x69, 0x74, 0x73, 0x65, 0x72, 0x76,
0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x1a, 0x2e, 0x67, 0x69, 0x74, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31,
0x2e, 0x45, 0x78, 0x65, 0x63, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30,
0x01, 0x12, 0x47, 0x0a, 0x06, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x1b, 0x2e, 0x67, 0x69,
0x74, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63,
0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1c, 0x2e, 0x67, 0x69, 0x74, 0x73, 0x65,
0x72, 0x76, 0x65, 0x72, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69,
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67,
0x72, 0x61, 0x70, 0x68, 0x2f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x67, 0x72, 0x61, 0x70, 0x68,
0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x67, 0x69, 0x74, 0x73, 0x65, 0x72,
0x76, 0x65, 0x72, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@ -117,10 +117,10 @@ message BooleanNode {
}
enum OperatorKind {
UNSPECIFIED = 0;
AND = 1;
OR = 2;
NOT = 3;
OPERATOR_KIND_UNSPECIFIED = 0;
OPERATOR_KIND_AND = 1;
OPERATOR_KIND_OR = 2;
OPERATOR_KIND_NOT = 3;
}
message OperatorNode {