tag handling is still bad

This commit is contained in:
Jeff Carr 2025-09-12 14:53:39 -05:00
parent 62e5fc396c
commit 6654dbb410
5 changed files with 48 additions and 7 deletions

View File

@ -144,8 +144,7 @@ func (repo *Repo) gitVersionByName(name string) (string, error) {
return strings.TrimSpace(output), nil return strings.TrimSpace(output), nil
} }
if !repo.IsBranch(name) { if !repo.IsBranch(name) {
// tag does not exist // branch does not exist
// log.Log(WARN, "LocalTagExists()", name, "did not exist")
return "", errors.New("gitDescribeByName() git fatal: Not a valid object name: " + name) return "", errors.New("gitDescribeByName() git fatal: Not a valid object name: " + name)
} }
cmd := []string{"git", "describe", "--tags", name} cmd := []string{"git", "describe", "--tags", name}

View File

@ -83,8 +83,6 @@ func (repo *Repo) IsDevelRemote() bool {
// eventually this will be worked out by forge in some future code that hasn't been made 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 { func (repo *Repo) IsBranch(findname string) bool {
for t := range repo.Tags.IterAll() { for t := range repo.Tags.IterAll() {
// log.Info("LocalTagExists() tag:", t.Refname)
tagname := t.Refname tagname := t.Refname
if strings.HasPrefix(tagname, "refs/remotes") { if strings.HasPrefix(tagname, "refs/remotes") {
continue continue
@ -103,10 +101,8 @@ func (repo *Repo) IsBranch(findname string) bool {
func (repo *Repo) IsLocalBranch(findname string) bool { func (repo *Repo) IsLocalBranch(findname string) bool {
for t := range repo.Tags.IterAll() { for t := range repo.Tags.IterAll() {
if !strings.HasPrefix(t.Refname, "refs/heads") { if !strings.HasPrefix(t.Refname, "refs/heads") {
// log.Info("LocalTagExists() skip tag:", t.Refname)
continue continue
} }
// log.Info("LocalTagExists() check tag:", t.Refname)
path, filename := filepath.Split(t.Refname) path, filename := filepath.Split(t.Refname)
log.Log(INFO, "gitpb.IsBranch() tag:", path, filename, "from", repo.GetGoPath()) log.Log(INFO, "gitpb.IsBranch() tag:", path, filename, "from", repo.GetGoPath())
if filename == findname { if filename == findname {

41
gitTag.printTable.go Normal file
View File

@ -0,0 +1,41 @@
// Code generated by go.wit.com/apps/autogenpb DO NOT EDIT.
// This file was autogenerated with autogenpb v0.5.1 2025-09-12_15:24:32_UTC
// go install go.wit.com/apps/autogenpb@latest
//
// define which structs (messages) you want to use in the .proto file
// Then sort.pb.go and marshal.pb.go files are autogenerated
//
// autogenpb uses it and has an example .proto file with instructions
//
package gitpb
import (
"go.wit.com/lib/cobol"
)
func (mt *GitTagsTable) PrintTable() {
// log.Info("ShowTable() SENDING TO GUI")
mt.MakeTable()
cobol.PrintTable(mt.pb)
}
/*
func (mt *GitTagsTable) MakeTable() {
for _, name := range mt.pb.Order {
// log.Info("gitpb: looking for row name()", name)
if mt.doStringFunc(name) {
continue
}
if mt.doIntFunc(name) {
continue
}
if mt.doTimeFunc(name) {
continue
}
if mt.doButtonFunc(name) {
continue
}
}
}
*/

View File

@ -33,7 +33,7 @@ message GitTag { // `autogenpb:nomutex`
string subject = 5; // git tag subject string subject = 5; // git tag subject
} }
message GitTags { // `autogenpb:marshal` `autogenpb:nomutex` message GitTags { // `autogenpb:marshal` `autogenpb:nomutex` `autogenpb:gui`
string uuid = 1; // `autogenpb:uuid:ffdff813-0316-4372-9e82-4c1c7d202526` string uuid = 1; // `autogenpb:uuid:ffdff813-0316-4372-9e82-4c1c7d202526`
string version = 2; // `autogenpb:version:v0.0.47` string version = 2; // `autogenpb:version:v0.0.47`
repeated GitTag gitTags = 3; repeated GitTag gitTags = 3;

View File

@ -168,11 +168,16 @@ func (repo *Repo) NewestTag() *GitTag {
} }
// this should just do is.Exists(".git/refs/heads/findname") // this should just do is.Exists(".git/refs/heads/findname")
// this is a simple check and doesn't work all the time
func (repo *Repo) LocalTagExists(findname string) bool { func (repo *Repo) LocalTagExists(findname string) bool {
fname := filepath.Join(".git/refs/heads", findname) fname := filepath.Join(".git/refs/heads", findname)
if repo.Exists(fname) { if repo.Exists(fname) {
return true return true
} }
fname = filepath.Join(".git/refs/tags", findname)
if repo.Exists(fname) {
return true
}
/* /*
loop := repo.Tags.SortByRefname() loop := repo.Tags.SortByRefname()
for loop.Scan() { for loop.Scan() {