mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-09-20 07:21:22 +00:00
Generated go.sum and proto file detection
This commit is contained in:
parent
ed2adad159
commit
fe195c67a9
@ -96,6 +96,9 @@ var GeneratedCodeNameMatchers = []GeneratedCodeNameMatcher{
|
|||||||
|
|
||||||
// Poetry lock
|
// Poetry lock
|
||||||
nameEndsWith("poetry.lock"),
|
nameEndsWith("poetry.lock"),
|
||||||
|
|
||||||
|
// go mod sum file
|
||||||
|
nameEndsWith("go.sum"),
|
||||||
}
|
}
|
||||||
|
|
||||||
// GeneratedCodeMatcher checks whether the file with the given data is
|
// GeneratedCodeMatcher checks whether the file with the given data is
|
||||||
@ -113,6 +116,7 @@ var GeneratedCodeMatchers = []GeneratedCodeMatcher{
|
|||||||
isGeneratedJavaScriptPEGParser,
|
isGeneratedJavaScriptPEGParser,
|
||||||
isGeneratedPostScript,
|
isGeneratedPostScript,
|
||||||
isGeneratedGo,
|
isGeneratedGo,
|
||||||
|
isGeneratedProtobufFromGo,
|
||||||
isGeneratedProtobuf,
|
isGeneratedProtobuf,
|
||||||
isGeneratedJavaScriptProtocolBuffer,
|
isGeneratedJavaScriptProtocolBuffer,
|
||||||
isGeneratedApacheThrift,
|
isGeneratedApacheThrift,
|
||||||
@ -339,6 +343,24 @@ func isGeneratedGo(_, ext string, content []byte) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isGeneratedProtobufFromGo(_, ext string, content []byte) bool {
|
||||||
|
if ext != ".proto" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
lines := getLines(content, 20)
|
||||||
|
if len(lines) <= 1 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, line := range lines {
|
||||||
|
if bytes.Contains(line, []byte("This file was autogenerated by go-to-protobuf")) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
var protoExtensions = map[string]struct{}{
|
var protoExtensions = map[string]struct{}{
|
||||||
".py": {},
|
".py": {},
|
||||||
".java": {},
|
".java": {},
|
||||||
|
Loading…
Reference in New Issue
Block a user