Compare commits

...

3 Commits

Author SHA1 Message Date
Jeff Carr ab666ddbc3 rm old code 2025-09-16 23:25:22 -05:00
Jeff Carr 0b30cd36dc misc 2025-09-16 09:32:36 -05:00
Jeff Carr 2a47f1e547 cleaning up obscure git cases 2025-09-13 05:33:31 -05:00
6 changed files with 13 additions and 41 deletions

View File

@ -2,7 +2,6 @@ package gitpb
import (
"fmt"
"os"
"os/user"
"path/filepath"
@ -11,20 +10,6 @@ import (
func (repo *Repo) CheckoutMaster() bool {
bName := repo.GetMasterBranchName()
if bName == "giterr" {
cmd := []string{"git", "checkout", "main"} // todo: figure out main
repo.RunVerboseOnError(cmd)
os.Exit(-1)
// TODO: try to fix this
if repo.checkoutBranch("main") {
repo.MasterBranchName = "main"
return true
} else {
cmd := []string{"git", "checkout", "main"} // todo: figure out main
repo.RunVerboseOnError(cmd)
return false
}
}
if repo.checkoutBranch(bName) {
return true
}

View File

@ -14,7 +14,10 @@ func (repo *Repo) SetMasterBranchName(s string) {
func (repo *Repo) GetGoPath() string {
if repo.GoInfo == nil {
return ""
return repo.Namespace
}
if repo.GoInfo.GoPath == "" {
return repo.Namespace
}
return repo.GoInfo.GoPath
}

View File

@ -19,6 +19,11 @@ func (all *Repos) ConfigSave(fname string) error {
return errors.New("gitpb.ConfigSave() repos == nil")
}
if _, s := filepath.Split(fname); s != "repos.pb" {
log.Infof("ConfigSave() filename '%s' invalid\n", fname)
return log.Errorf("ConfigSave() filename '%s' invalid\n", fname)
}
data, err := all.Marshal()
if err != nil {
log.Info("gitpb proto.Marshal() failed len", len(data), err)

View File

@ -38,7 +38,6 @@ func (repo *Repo) setMasterVersion() {
repo.MasterVersion = v
} else {
log.Log(WARN, "gitpb.GitMasterVersion() error:", err)
repo.MasterVersion = "giterr"
}
}
@ -134,11 +133,11 @@ func (repo *Repo) gitVersionByName(name string) (string, error) {
if name == "" {
// git will return the current tag
r, err := repo.RunQuiet([]string{"git", "describe", "--tags"})
cmd := []string{"git", "describe", "--tags"}
r, err := repo.RunQuiet(cmd)
output := strings.Join(r.Stdout, "\n")
if err != nil {
log.Log(WARN, "gitDescribeByName() output might have worked anyway:", output)
log.Log(WARN, "gitDescribeByName() not in a git repo?", err, repo.GetGoPath())
log.Log(WARN, repo.FullPath, "gitDescribeByName() ", output, err, cmd)
return "", err
}
return strings.TrimSpace(output), nil

View File

@ -19,23 +19,3 @@ func (mt *GitTagsTable) PrintTable() {
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

@ -10,7 +10,7 @@
package gitpb
func (t *ReposTable) MyMasterBranch() *RepoStringFunc {
func (t *ReposTable) MyMasterBranch() *RepoAnyFunc {
sf := t.AddStringFunc("master", func(m *Repo) string {
return m.MasterBranchName
})