From 0bf8cc3d79257f7245d9591d6811ab1207cfddba Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 19 Mar 2025 06:40:32 -0500 Subject: now using the awesome golang 1.24 'iter' --- gitTag.common.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) (limited to 'gitTag.common.go') diff --git a/gitTag.common.go b/gitTag.common.go index c41f7c1..f10548e 100644 --- a/gitTag.common.go +++ b/gitTag.common.go @@ -10,9 +10,7 @@ import ( func (repo *Repo) DevelHash() string { brname := repo.GetDevelBranchName() refname := "refs/heads/" + brname - all := repo.Tags.All() - for all.Scan() { - tag := all.Next() + for tag := range repo.Tags.IterAll() { // log.Info("repo tag", tag.GetHash(), tag.GetRefname()) if tag.GetRefname() == refname { return tag.GetHash() @@ -23,9 +21,7 @@ func (repo *Repo) DevelHash() string { func (repo *Repo) GetLocalHash(brname string) string { refname := "refs/heads/" + brname - all := repo.Tags.All() - for all.Scan() { - tag := all.Next() + for tag := range repo.Tags.IterAll() { // log.Info("repo tag", tag.GetHash(), tag.GetRefname()) if tag.GetRefname() == refname { return strings.TrimSpace(tag.GetHash()) @@ -36,9 +32,7 @@ func (repo *Repo) GetLocalHash(brname string) string { func (repo *Repo) GetRemoteHash(brname string) string { refname := "refs/remotes/origin/" + brname - all := repo.Tags.All() - for all.Scan() { - tag := all.Next() + for tag := range repo.Tags.IterAll() { // log.Info("repo tag", tag.GetHash(), tag.GetRefname()) if tag.GetRefname() == refname { return strings.TrimSpace(tag.GetHash()) @@ -88,9 +82,7 @@ func (repo *Repo) IsDevelRemote() bool { // matter much here yet // eventually this will be worked out by forge in some future code that hasn't been made yet func (repo *Repo) IsBranch(findname string) bool { - loop := repo.Tags.All() - for loop.Scan() { - t := loop.Next() + for t := range repo.Tags.IterAll() { // log.Info("LocalTagExists() tag:", t.Refname) tagname := t.Refname @@ -109,9 +101,7 @@ func (repo *Repo) IsBranch(findname string) bool { } func (repo *Repo) IsLocalBranch(findname string) bool { - loop := repo.Tags.All() - for loop.Scan() { - t := loop.Next() + for t := range repo.Tags.IterAll() { if !strings.HasPrefix(t.Refname, "refs/heads") { // log.Info("LocalTagExists() skip tag:", t.Refname) continue @@ -131,9 +121,7 @@ func (repo *Repo) IsLocalBranch(findname string) bool { // finds the newest tag. used for deciding if master needs to be published func (repo *Repo) FindLastTag() string { var newest *GitTag - all := repo.Tags.All() - for all.Scan() { - tag := all.Next() + for tag := range repo.Tags.IterAll() { if !strings.HasPrefix(tag.GetRefname(), "refs/tags/") { continue } -- cgit v1.2.3