diff options
Diffstat (limited to 'gitTag.update.go')
| -rw-r--r-- | gitTag.update.go | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gitTag.update.go b/gitTag.update.go index 8a7cea0..c8a35c3 100644 --- a/gitTag.update.go +++ b/gitTag.update.go @@ -1,6 +1,7 @@ package gitpb import ( + "path/filepath" "slices" "strings" "time" @@ -93,3 +94,46 @@ func (repo *Repo) NewestTag() *GitTag { } return nil } + +func (repo *Repo) LocalTagExists(findname string) bool { + loop := repo.Tags.SortByRefname() + for loop.Scan() { + ref := loop.Next() + // log.Info(repo.GoPath, ref.Refname) + if strings.HasPrefix(ref.Refname, "refs/remotes") { + continue + } + _, tagname := filepath.Split(ref.Refname) + // log.Info("tag:", path, tagname, "from", repo.GoPath) + if tagname == findname { + // log.Info("found tag:", path, tagname, "from", repo.GoPath) + return true + } + } + return false +} + +// returns true if 'taggy' is _ONLY_ a local tag +// this means you can not do a git pull or git push on it +func (repo *Repo) IsOnlyLocalTag(taggy string) bool { + // first make sure the tag is actually even local + if !repo.LocalTagExists(taggy) { + // this means it's not even local now. + return false + } + // okay, taggy exists, does it exist in a remote repo? + loop := repo.Tags.SortByRefname() + for loop.Scan() { + ref := loop.Next() + tagname := ref.Refname + if strings.HasPrefix(tagname, "refs/remotes") { + path, filename := filepath.Split(tagname) + if filename == taggy { + log.Log(GITPB, "found tag:", path, filename, "from", repo.GetGoPath()) + return false + } + } + } + // we couldn't find the local tag anywhere remote, so it's probably only local + return true +} |
