Use proper error to stop iteration

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-07-13 11:51:11 +03:00
parent 2f1de6fc41
commit 77aa221efe

View file

@ -1,7 +1,6 @@
package main package main
import ( import (
"errors"
"fmt" "fmt"
"log" "log"
"os" "os"
@ -11,6 +10,7 @@ import (
git "github.com/go-git/go-git/v5" git "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/plumbing/object" "github.com/go-git/go-git/v5/plumbing/object"
"github.com/go-git/go-git/v5/plumbing/storer"
gha "github.com/sethvargo/go-githubactions" gha "github.com/sethvargo/go-githubactions"
) )
@ -49,7 +49,7 @@ func main() {
_ = commits.ForEach(func(c *object.Commit) error { _ = commits.ForEach(func(c *object.Commit) error {
// Stop iterator when limit is reached. // Stop iterator when limit is reached.
if lca != nil && c.Hash == lca.Hash { if lca != nil && c.Hash == lca.Hash {
return errors.New("stop") return storer.ErrStop
} }
// Parse commit data. // Parse commit data.