Compare commits

..

No commits in common. "master" and "v0.0.126" have entirely different histories.

6 changed files with 41 additions and 13 deletions

View File

@ -2,6 +2,7 @@ package gitpb
import ( import (
"fmt" "fmt"
"os"
"os/user" "os/user"
"path/filepath" "path/filepath"
@ -10,6 +11,20 @@ import (
func (repo *Repo) CheckoutMaster() bool { func (repo *Repo) CheckoutMaster() bool {
bName := repo.GetMasterBranchName() 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) { if repo.checkoutBranch(bName) {
return true return true
} }

View File

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

View File

@ -19,11 +19,6 @@ func (all *Repos) ConfigSave(fname string) error {
return errors.New("gitpb.ConfigSave() repos == nil") 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() data, err := all.Marshal()
if err != nil { if err != nil {
log.Info("gitpb proto.Marshal() failed len", len(data), err) log.Info("gitpb proto.Marshal() failed len", len(data), err)

View File

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

View File

@ -19,3 +19,23 @@ func (mt *GitTagsTable) PrintTable() {
mt.MakeTable() mt.MakeTable()
cobol.PrintTable(mt.pb) 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 package gitpb
func (t *ReposTable) MyMasterBranch() *RepoAnyFunc { func (t *ReposTable) MyMasterBranch() *RepoStringFunc {
sf := t.AddStringFunc("master", func(m *Repo) string { sf := t.AddStringFunc("master", func(m *Repo) string {
return m.MasterBranchName return m.MasterBranchName
}) })