From 22046243699a4cad639a749410b19ce52211cda8 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 21 Feb 2025 10:21:25 -0600 Subject: [PATCH] for forge --- gitTag.common.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gitTag.common.go b/gitTag.common.go index 43c0dbc..81e44c3 100644 --- a/gitTag.common.go +++ b/gitTag.common.go @@ -21,6 +21,32 @@ func (repo *Repo) DevelHash() string { return "" } +func (repo *Repo) GetLocalHash(brname string) string { + refname := "refs/heads/" + brname + all := repo.Tags.All() + for all.Scan() { + tag := all.Next() + // log.Info("repo tag", tag.GetHash(), tag.GetRefname()) + if tag.GetRefname() == refname { + return strings.TrimSpace(tag.GetHash()) + } + } + return "" +} + +func (repo *Repo) GetRemoteHash(brname string) string { + refname := "refs/remotes/origin/" + brname + all := repo.Tags.All() + for all.Scan() { + tag := all.Next() + // log.Info("repo tag", tag.GetHash(), tag.GetRefname()) + if tag.GetRefname() == refname { + return strings.TrimSpace(tag.GetHash()) + } + } + return "" +} + // this is the correct way. uses 'git show-ref' func (repo *Repo) IsBranchRemote(brname string) bool { if repo.Tags == nil {