deprecate refs.proto ?
This commit is contained in:
parent
c49d247ae8
commit
3359a44996
|
@ -17,8 +17,8 @@ func (repo *Repo) GetLastTag() string {
|
||||||
log.Info("getLastTagVersion()", result.Stdout)
|
log.Info("getLastTagVersion()", result.Stdout)
|
||||||
|
|
||||||
if len(result.Stdout) != 1 {
|
if len(result.Stdout) != 1 {
|
||||||
log.Info("git LastTag() error:", result.Stdout)
|
log.Log(GITPBWARN, "git LastTag() error:", result.Stdout)
|
||||||
return "error"
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
hash := result.Stdout[0]
|
hash := result.Stdout[0]
|
||||||
|
@ -27,8 +27,8 @@ func (repo *Repo) GetLastTag() string {
|
||||||
result = repo.RunQuiet(cmd)
|
result = repo.RunQuiet(cmd)
|
||||||
|
|
||||||
if len(result.Stdout) != 1 {
|
if len(result.Stdout) != 1 {
|
||||||
log.Info("git LastTag() error:", result.Stdout)
|
log.Log(GITPBWARN, "git LastTag() error:", result.Stdout)
|
||||||
return "error"
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.Stdout[0]
|
return result.Stdout[0]
|
||||||
|
@ -37,18 +37,18 @@ func (repo *Repo) GetLastTag() string {
|
||||||
func (repo *Repo) GitMasterVersion() string {
|
func (repo *Repo) GitMasterVersion() string {
|
||||||
v, err := repo.gitVersionByName("master")
|
v, err := repo.gitVersionByName("master")
|
||||||
/*
|
/*
|
||||||
count := repo.LenGitTags()
|
count := repo.LenGitTags()
|
||||||
log.Info(repo.GoPath, "tag count", count)
|
log.Info(repo.GoPath, "tag count", count)
|
||||||
repo.UpdateGitTags()
|
repo.UpdateGitTags()
|
||||||
count = repo.LenGitTags()
|
count = repo.LenGitTags()
|
||||||
log.Info(repo.GoPath, "tag count", count)
|
log.Info(repo.GoPath, "tag count", count)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return v
|
return v
|
||||||
} else {
|
} else {
|
||||||
log.Info("GitMasterVersion() error", err)
|
log.Log(GITPBWARN, "gitpb.GitMasterVersion() error:", err)
|
||||||
return "error"
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,8 +57,8 @@ func (repo *Repo) GitDevelVersion() string {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return v
|
return v
|
||||||
} else {
|
} else {
|
||||||
log.Info("GitMasterVersion() error", err)
|
log.Log(GITPBWARN, "gitpb.GitDevelVersion() error:", err)
|
||||||
return "error"
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ func (repo *Repo) GitUserVersion() string {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return v
|
return v
|
||||||
} else {
|
} else {
|
||||||
log.Info("GitMasterVersion() error", err)
|
log.Log(GITPBWARN, "gitpb.GitUserVersion() error:", err)
|
||||||
return "error"
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,28 +80,39 @@ func (repo *Repo) gitVersionByName(name string) (string, error) {
|
||||||
r := repo.RunQuiet([]string{"git", "describe", "--tags", "--always"})
|
r := repo.RunQuiet([]string{"git", "describe", "--tags", "--always"})
|
||||||
output := strings.Join(r.Stdout, "\n")
|
output := strings.Join(r.Stdout, "\n")
|
||||||
if r.Error != nil {
|
if r.Error != nil {
|
||||||
log.Warn("gitDescribeByName() not in a git repo?", r.Error, repo.GoPath)
|
log.Log(GITPBWARN, "gitDescribeByName() output might have worked anyway:", output)
|
||||||
|
log.Log(GITPBWARN, "gitDescribeByName() not in a git repo?", r.Error, repo.GoPath)
|
||||||
|
return "", r.Error
|
||||||
}
|
}
|
||||||
return strings.TrimSpace(output), r.Error
|
return strings.TrimSpace(output), nil
|
||||||
}
|
}
|
||||||
if !repo.LocalTagExists(name) {
|
if ! repo.IsBranch(name) {
|
||||||
// tag does not exist
|
// tag does not exist
|
||||||
log.Warn("LocalTagExists()", name, "did not exist")
|
log.Log(GITPBWARN, "LocalTagExists()", name, "did not exist")
|
||||||
return "", errors.New("gitDescribeByName() git fatal: Not a valid object name")
|
return "", errors.New("gitDescribeByName() git fatal: Not a valid object name: " + name)
|
||||||
}
|
}
|
||||||
cmd := []string{"git", "describe", "--tags", "--always", name}
|
cmd := []string{"git", "describe", "--tags", "--always", name}
|
||||||
result := repo.RunQuiet(cmd)
|
result := repo.RunQuiet(cmd)
|
||||||
output := strings.Join(result.Stdout, "\n")
|
output := strings.Join(result.Stdout, "\n")
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
log.Warn("cmd =", cmd)
|
log.Log(GITPBWARN, "cmd =", cmd)
|
||||||
log.Warn("err =", result.Error)
|
log.Log(GITPBWARN, "err =", result.Error)
|
||||||
log.Warn("not in a git repo or bad tag?", repo.GoPath)
|
log.Log(GITPBWARN, "output (might have worked with error?) =", output)
|
||||||
|
log.Log(GITPBWARN, "not in a git repo or bad tag?", repo.GoPath)
|
||||||
|
return "", result.Error
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.TrimSpace(output), result.Error
|
return strings.TrimSpace(output), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (repo *Repo) LocalTagExists(findname string) bool {
|
// find a branch name
|
||||||
|
// will find "master" or "devel"
|
||||||
|
// will also find "v0.1.1"
|
||||||
|
// or will find "patches-from-foo"
|
||||||
|
// will return *any* match on any git branch because it doesn't
|
||||||
|
// matter much here yet
|
||||||
|
// eventually this will be worked out by forge in some future code that hasn't been made yet
|
||||||
|
func (repo *Repo) IsBranch(findname string) bool {
|
||||||
loop := repo.AllTags()
|
loop := repo.AllTags()
|
||||||
for loop.Scan() {
|
for loop.Scan() {
|
||||||
t := loop.Next()
|
t := loop.Next()
|
||||||
|
@ -112,9 +123,9 @@ func (repo *Repo) LocalTagExists(findname string) bool {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
path, filename := filepath.Split(tagname)
|
path, filename := filepath.Split(tagname)
|
||||||
log.Log(GITPB, "LocalTagExists() tag:", path, filename, "from", repo.GoPath)
|
log.Log(GITPB, "gitpb.IsBranch() tag:", path, filename, "from", repo.GoPath)
|
||||||
if filename == findname {
|
if filename == findname {
|
||||||
log.Log(GITPB, "found tag:", path, filename, "from", repo.GoPath)
|
log.Log(GITPB, "gitpb.IsBranch() found tag:", path, filename, "from", repo.GoPath)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,6 @@
|
||||||
package gitpb
|
package gitpb
|
||||||
|
|
||||||
import (
|
/*
|
||||||
"slices"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/lib/gui/shell"
|
|
||||||
"go.wit.com/log"
|
|
||||||
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Update repo.Refs from .git/
|
// Update repo.Refs from .git/
|
||||||
func (repo *Repo) UpdateGit() error {
|
func (repo *Repo) UpdateGit() error {
|
||||||
// delete the old hash
|
// delete the old hash
|
||||||
|
@ -61,3 +52,4 @@ func (repo *Repo) UpdateGit() error {
|
||||||
repo.AppendRef(&newr)
|
repo.AppendRef(&newr)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
|
@ -33,7 +33,7 @@ func (all *Repos) NewGoPath(basepath string, gopath string) (*Repo, error) {
|
||||||
FullPath: filepath.Join(basepath, gopath),
|
FullPath: filepath.Join(basepath, gopath),
|
||||||
GoPath: gopath,
|
GoPath: gopath,
|
||||||
}
|
}
|
||||||
newr.UpdateGit()
|
// newr.UpdateGit()
|
||||||
newr.UpdateGitTags()
|
newr.UpdateGitTags()
|
||||||
|
|
||||||
all.add(&newr)
|
all.add(&newr)
|
||||||
|
|
Loading…
Reference in New Issue