From 96d578a30a157fa6dc4c66f95f4cab953fbebfb7 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 17 Dec 2024 15:46:57 +0100 Subject: pkg/vcs: extend ListCommitHashes Support filtering by the commit date. --- pkg/vcs/git.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'pkg/vcs/git.go') diff --git a/pkg/vcs/git.go b/pkg/vcs/git.go index b75859338..d8a4967ba 100644 --- a/pkg/vcs/git.go +++ b/pkg/vcs/git.go @@ -381,11 +381,18 @@ func (git *git) GetCommitsByTitles(titles []string) ([]*Commit, []string, error) return results, missing, nil } -func (git *git) ListCommitHashes(baseCommit string) ([]string, error) { - output, err := git.git("log", "--pretty=format:%h", baseCommit) +func (git *git) ListCommitHashes(baseCommit string, from time.Time) ([]string, error) { + args := []string{"log", "--pretty=format:%h"} + if !from.IsZero() { + args = append(args, "--since", from.Format(time.RFC3339)) + } + output, err := git.git(append(args, baseCommit)...) if err != nil { return nil, err } + if len(output) == 0 { + return nil, nil + } return strings.Split(string(output), "\n"), nil } -- cgit mrf-deployment