From b57144e6bfe8a6b63d2d2f8ffb47af04a926ae8b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 29 Jan 2025 20:01:07 -0600 Subject: some useful helper functions --- branches.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'branches.go') diff --git a/branches.go b/branches.go index ec86c20..1c923dd 100644 --- a/branches.go +++ b/branches.go @@ -123,3 +123,18 @@ func (repo *Repo) GetHashName(h string) (string, error) { } return r.Stdout[0], nil } + +// lookup a hash from a tag with 'git rev-list' +func (repo *Repo) GetTagHash(t string) string { + // git rev-list -n 1 v0.0.66 + cmd := []string{"git", "rev-list", "-n", "1", t} + result, _ := repo.RunStrictNew(cmd) + // log.Info("getLastTagVersion()", result.Stdout) + + if len(result.Stdout) == 0 { + // log.Log(WARN, "no gitpb.LastTag() repo is broken. ignore this.", repo.GetGoPath()) + return "" + } + + return result.Stdout[0] +} -- cgit v1.2.3