get devel and user versions
This commit is contained in:
parent
96d37b5941
commit
d283d2d297
|
@ -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
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -36,7 +36,7 @@ func (it *GitTagIterator) Scan() bool {
|
|||
}
|
||||
|
||||
// GitTag returns the current repo.
|
||||
func (it *GitTagIterator) GitTag() *GitTag {
|
||||
func (it *GitTagIterator) Next() *GitTag {
|
||||
if it.packs[it.index-1] == nil {
|
||||
for i, d := range it.packs {
|
||||
fmt.Println("i =", i, d)
|
||||
|
@ -124,7 +124,7 @@ func (repo *Repo) selectAllGitTags() []*GitTag {
|
|||
gitTagslock.RLock()
|
||||
defer gitTagslock.RUnlock()
|
||||
|
||||
// Create a new slice to hold pointers to eachGitTag
|
||||
// Create a new slice to hold pointers to eachGitTag
|
||||
var allGitTags []*GitTag
|
||||
allGitTags = make([]*GitTag, len(repo.GitTags))
|
||||
for i, p := range repo.GitTags {
|
||||
|
|
|
@ -55,17 +55,17 @@ func (repo *Repo) UpdateGitTags() error {
|
|||
}
|
||||
refname = parts[3]
|
||||
subject = parts[4]
|
||||
}
|
||||
|
||||
newr := GitTag{
|
||||
Refname: refname,
|
||||
Objectname: hash,
|
||||
Subject: subject,
|
||||
Creatordate: ctime,
|
||||
Authordate: atime,
|
||||
}
|
||||
newr := GitTag{
|
||||
Refname: refname,
|
||||
Objectname: hash,
|
||||
Subject: subject,
|
||||
Creatordate: ctime,
|
||||
Authordate: atime,
|
||||
}
|
||||
|
||||
repo.AppendGitTag(&newr)
|
||||
repo.AppendGitTag(&newr)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue