From cb8a27df9ae862670308d49ed2a8992157564ae7 Mon Sep 17 00:00:00 2001 From: Ilya Dmitrichenko Date: Mon, 9 Oct 2023 12:52:12 +0100 Subject: [PATCH] WIP --- attest/vcs/git/git.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/attest/vcs/git/git.go b/attest/vcs/git/git.go index 7a04757..990c148 100644 --- a/attest/vcs/git/git.go +++ b/attest/vcs/git/git.go @@ -211,19 +211,14 @@ func (c *PathChecker) MakeSummary() (types.PathCheckSummary, error) { object.NewCommitIterCTime(headCommit, nil, nil), true, ) - - if err := commitIter.ForEach(func(commit *object.Commit) error { - if obj.CommitHash != "" { - return nil - } + defer commitIter.Close() + // only need first commit, avoid looping over all commits with ForEach + commit, err := commitIter.Next() + if err == nil { obj.CommitHash = commit.Hash.String() - return nil - - }); err != nil { + } else if err != io.EOF { return nil, err } - - defer commitIter.Close() } tags, err := c.cache.repo.Tags() @@ -232,7 +227,6 @@ func (c *PathChecker) MakeSummary() (types.PathCheckSummary, error) { } if err := tags.ForEach(func(t *plumbing.Reference) error { - target, err := c.cache.repo.ResolveRevision(plumbing.Revision(t.Name())) if err != nil { return err