Metadata tool correction: Output empty proto in case of no input
Change-Id: I85ca22574433ab164c303c1f6b0d29191e704cbb
This commit is contained in:
@@ -77,9 +77,18 @@ func readFileToString(filePath string) string {
|
|||||||
return string(data)
|
return string(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeNewlineToOutputFile(outputFile string) {
|
func writeEmptyOutputProto(outputFile string, metadataRule string) {
|
||||||
file, err := os.Create(outputFile)
|
file, err := os.Create(outputFile)
|
||||||
data := "\n"
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
var message proto.Message
|
||||||
|
if metadataRule == "test_spec" {
|
||||||
|
message = &test_spec_proto.TestSpec{}
|
||||||
|
} else if metadataRule == "code_metadata" {
|
||||||
|
message = &code_metadata_proto.CodeMetadata{}
|
||||||
|
}
|
||||||
|
data, err := proto.Marshal(message)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
@@ -235,7 +244,7 @@ func main() {
|
|||||||
inputFileData := strings.TrimRight(readFileToString(*inputFile), "\n")
|
inputFileData := strings.TrimRight(readFileToString(*inputFile), "\n")
|
||||||
filePaths := strings.Split(inputFileData, " ")
|
filePaths := strings.Split(inputFileData, " ")
|
||||||
if len(filePaths) == 1 && filePaths[0] == "" {
|
if len(filePaths) == 1 && filePaths[0] == "" {
|
||||||
writeNewlineToOutputFile(*outputFile)
|
writeEmptyOutputProto(*outputFile, *rule)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ownershipMetadataMap := &sync.Map{}
|
ownershipMetadataMap := &sync.Map{}
|
||||||
|
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
|
Reference in New Issue
Block a user