Merge pull request #133 from lafriks-fork/feat/generated_files_proto_go_sum

Generated proto file and PNP detection
This commit is contained in:
Alex 2022-10-06 10:01:35 +02:00 committed by GitHub
commit 9b19067edc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,7 +74,7 @@ var GeneratedCodeNameMatchers = []GeneratedCodeNameMatcher{
nameEndsWith("package-lock.json"), nameEndsWith("package-lock.json"),
// Yarn plugnplay // Yarn plugnplay
nameMatches(`(^|\/)\.pnp\.(c|m)?js$`), nameMatches(`(^|\/)\.pnp\..*$`),
// Godeps // Godeps
nameContains("Godeps/"), nameContains("Godeps/"),
@ -113,6 +113,7 @@ var GeneratedCodeMatchers = []GeneratedCodeMatcher{
isGeneratedJavaScriptPEGParser, isGeneratedJavaScriptPEGParser,
isGeneratedPostScript, isGeneratedPostScript,
isGeneratedGo, isGeneratedGo,
isGeneratedProtobufFromGo,
isGeneratedProtobuf, isGeneratedProtobuf,
isGeneratedJavaScriptProtocolBuffer, isGeneratedJavaScriptProtocolBuffer,
isGeneratedApacheThrift, isGeneratedApacheThrift,
@ -339,6 +340,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": {},