diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-12-17 15:46:57 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-01-03 10:31:18 +0000 |
| commit | 96d578a30a157fa6dc4c66f95f4cab953fbebfb7 (patch) | |
| tree | 72446ff1f5cd4c13405f1abe0c3c0611b4aacc4c /pkg/vcs/git.go | |
| parent | d3ccff6372e07c6aabd02b5da419aa6492b5f0ad (diff) | |
pkg/vcs: extend ListCommitHashes
Support filtering by the commit date.
Diffstat (limited to 'pkg/vcs/git.go')
| -rw-r--r-- | pkg/vcs/git.go | 11 |
1 files changed, 9 insertions, 2 deletions
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 } |
