From 09706c899ce54513472d621bf9d84c0e8e5eaea8 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Mon, 12 May 2025 15:29:02 +0200 Subject: pkg/vcs: extend ListCommitHashes Rename the method to LatestCommit and make it more flexible: 1) Return the commit date alongside the commit hash. 2) Rename the time filter to highlight that it's non-inclusive. 3) Make it possible to query the commits newer than the specified commit hash. It will let us poll lore archives more efficiently. --- pkg/email/lore/read.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'pkg/email') diff --git a/pkg/email/lore/read.go b/pkg/email/lore/read.go index ef0a0faa0..d4e68cf33 100644 --- a/pkg/email/lore/read.go +++ b/pkg/email/lore/read.go @@ -13,12 +13,13 @@ import ( ) type EmailReader struct { + vcs.CommitShort Read func() ([]byte, error) } // ReadArchive queries the parsed messages from a single LKML message archive. -func ReadArchive(repo vcs.Repo, fromTime time.Time) ([]EmailReader, error) { - commits, err := repo.ListCommitHashes("HEAD", fromTime) +func ReadArchive(repo vcs.Repo, afterCommit string, afterTime time.Time) ([]EmailReader, error) { + commits, err := repo.LatestCommits(afterCommit, afterTime) if err != nil { return nil, fmt.Errorf("failed to get recent commits: %w", err) } @@ -26,8 +27,9 @@ func ReadArchive(repo vcs.Repo, fromTime time.Time) ([]EmailReader, error) { for _, iterCommit := range commits { commit := iterCommit ret = append(ret, EmailReader{ + CommitShort: commit, Read: func() ([]byte, error) { - return repo.Object("m", commit) + return repo.Object("m", commit.Hash) }, }) } -- cgit mrf-deployment