diff options
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] +} |
