diff options
Diffstat (limited to 'gitTags.query.go')
| -rw-r--r-- | gitTags.query.go | 72 |
1 files changed, 58 insertions, 14 deletions
diff --git a/gitTags.query.go b/gitTags.query.go index faea8e2..e145480 100644 --- a/gitTags.query.go +++ b/gitTags.query.go @@ -4,6 +4,10 @@ package gitpb // types faster than you can import ( + "errors" + "path/filepath" + "strings" + "go.wit.com/log" ) @@ -30,8 +34,45 @@ func (repo *Repo) GetLastTag() string { return result.Stdout[0] } -/* -func (repo *Repo) gitDescribeByName(name string) (string, error) { +func (repo *Repo) GitMasterVersion() string { + v, err := repo.gitVersionByName("master") + /* + count := repo.LenGitTags() + log.Info(repo.GoPath, "tag count", count) + repo.UpdateGitTags() + count = repo.LenGitTags() + log.Info(repo.GoPath, "tag count", count) + */ + + if err == nil { + return v + } else { + log.Info("GitMasterVersion() error", err) + return "error" + } +} + +func (repo *Repo) GitDevelVersion() string { + v, err := repo.gitVersionByName("devel") + if err == nil { + return v + } else { + log.Info("GitMasterVersion() error", err) + return "error" + } +} + +func (repo *Repo) GitUserVersion() string { + v, err := repo.gitVersionByName("jcarr") + if err == nil { + return v + } else { + log.Info("GitMasterVersion() error", err) + return "error" + } +} + +func (repo *Repo) gitVersionByName(name string) (string, error) { name = strings.TrimSpace(name) if name == "" { @@ -45,34 +86,37 @@ func (repo *Repo) gitDescribeByName(name string) (string, error) { } if !repo.LocalTagExists(name) { // tag does not exist + log.Warn("LocalTagExists()", name, "did not exist") return "", errors.New("gitDescribeByName() git fatal: Not a valid object name") } cmd := []string{"git", "describe", "--tags", "--always", name} - r := repo.RunQuiet(cmd) - output := strings.Join(r.Stdout, "\n") - if r.Error != nil { + result := repo.RunQuiet(cmd) + output := strings.Join(result.Stdout, "\n") + if result.Error != nil { log.Warn("cmd =", cmd) - log.Warn("err =", r.Error) - log.Warn("not in a git repo or bad tag?", rs.Path()) + log.Warn("err =", result.Error) + log.Warn("not in a git repo or bad tag?", repo.GoPath) } - return strings.TrimSpace(output), r.Error + return strings.TrimSpace(output), result.Error } func (repo *Repo) LocalTagExists(findname string) bool { - allTags := repo.Tags.ListAll() - for _, t := range allTags { - tagname := t.TagString() + loop := repo.AllTags() + for loop.Scan() { + t := loop.Next() + log.Info("tag:", t.Refname) + + tagname := t.Refname if strings.HasPrefix(tagname, "refs/remotes") { continue } path, filename := filepath.Split(tagname) - log.Log(INFO, "tag:", path, filename, "from", rs.Path()) + log.Log(GITPB, "tag:", path, filename, "from", repo.GoPath) if filename == findname { - log.Log(INFO, "found tag:", path, filename, "from", rs.Path()) + log.Log(GITPBWARN, "found tag:", path, filename, "from", repo.GoPath) return true } } return false } -*/ |
