diff options
| author | Jeff Carr <[email protected]> | 2025-01-29 20:01:07 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-29 20:01:07 -0600 |
| commit | b57144e6bfe8a6b63d2d2f8ffb47af04a926ae8b (patch) | |
| tree | 4f9823561ff5a44616e51cdd63f2d077149f7918 /branches.go | |
| parent | 19fb3a29fb6c5f157d78696c211d159d3748911a (diff) | |
some useful helper functions
Diffstat (limited to 'branches.go')
| -rw-r--r-- | branches.go | 15 |
1 files changed, 15 insertions, 0 deletions
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] +} |
