github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/email/lore/read.go (about) 1 // Copyright 2023 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package lore 5 6 import ( 7 "fmt" 8 9 "github.com/google/syzkaller/pkg/vcs" 10 ) 11 12 type EmailReader struct { 13 Extract func() ([]byte, error) 14 } 15 16 // ReadArchive queries the parsed messages from a single LKML message archive. 17 func ReadArchive(dir string, messages chan<- *EmailReader) error { 18 repo := vcs.NewLKMLRepo(dir) 19 commits, err := repo.ListCommitHashes("HEAD") 20 if err != nil { 21 return fmt.Errorf("failed to get recent commits: %w", err) 22 } 23 for _, iterCommit := range commits { 24 commit := iterCommit 25 messages <- &EmailReader{ 26 Extract: func() ([]byte, error) { 27 return repo.Object("m", commit) 28 }, 29 } 30 } 31 return nil 32 }