summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gitTag.common.go26
1 files changed, 26 insertions, 0 deletions
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 {