more moving to protobuf

This commit is contained in:
Jeff Carr 2024-12-03 18:03:09 -06:00
parent 1048ebc851
commit 73756cf5fa
1 changed files with 17 additions and 30 deletions

View File

@ -8,7 +8,6 @@ import (
"github.com/go-cmd/cmd" "github.com/go-cmd/cmd"
"go.wit.com/gui" "go.wit.com/gui"
"go.wit.com/lib/gui/repostatus"
"go.wit.com/log" "go.wit.com/log"
) )
@ -34,7 +33,7 @@ func (r *RepoList) FindByName(name string) *RepoRow {
loop := r.ReposSortByName() loop := r.ReposSortByName()
for loop.Scan() { for loop.Scan() {
repo := loop.Repo() repo := loop.Repo()
if repo.GoPath() == name { if repo.pb.GoPath == name {
return repo return repo
} }
base := filepath.Base(repo.GoPath()) base := filepath.Base(repo.GoPath())
@ -85,22 +84,19 @@ func (r *RepoRow) Scan() int {
// returns a name for human consuption only // returns a name for human consuption only
// todo: implement nicknames // todo: implement nicknames
func (rs *RepoRow) Name() string { func (rs *RepoRow) Name() string {
if rs.Status.IsGoLang() { return rs.pb.GoPath
return rs.Status.GoPath()
}
return rs.Status.Path()
} }
func (r *RepoRow) GoPath() string { func (r *RepoRow) GoPath() string {
return r.Status.GoPath() return r.pb.GoPath
} }
func (r *RepoRow) CheckDirty() bool { func (r *RepoRow) CheckDirty() bool {
return r.Status.CheckDirty() return r.pb.CheckDirty()
} }
func (r *RepoRow) IsDirty() bool { func (r *RepoRow) IsDirty() bool {
return r.Status.IsDirty() return r.pb.IsDirty()
} }
func (r *RepoRow) RepoType() string { func (r *RepoRow) RepoType() string {
@ -112,11 +108,11 @@ func (r *RepoRow) ReadOnly() bool {
log.Warn("ReadOnly() repo == nil") log.Warn("ReadOnly() repo == nil")
return false return false
} }
if r.Status == nil { if r.pb == nil {
log.Warn("ReadOnly() repo.Status == nil") log.Warn("ReadOnly() repo.pb == nil")
return false return false
} }
return r.Status.ReadOnly() return r.pb.ReadOnly
} }
func (r *RepoRow) LastTag() string { func (r *RepoRow) LastTag() string {
@ -138,9 +134,10 @@ func (r *RepoRow) IsPerfect() bool {
} }
func (r *RepoRow) Run(cmd []string) cmd.Status { func (r *RepoRow) Run(cmd []string) cmd.Status {
return r.Status.Run(cmd) return r.pb.Run(cmd)
} }
/*
func (r *RepoRow) AllTags() []*repostatus.Tag { func (r *RepoRow) AllTags() []*repostatus.Tag {
return r.Status.Tags.ListAll() return r.Status.Tags.ListAll()
} }
@ -154,6 +151,7 @@ func (r *RepoRow) DeleteTag(t *repostatus.Tag) bool {
r.Status.DeleteTag(t) r.Status.DeleteTag(t)
return true return true
} }
*/
func (rl *RepoList) MirrorShownCount() *gui.Node { func (rl *RepoList) MirrorShownCount() *gui.Node {
return gui.RawMirror(rl.shownCount) return gui.RawMirror(rl.shownCount)
@ -167,16 +165,6 @@ func (rl *RepoList) Total() int {
return len(me.allrepos) return len(me.allrepos)
} }
func (rl *RepoList) TotalGo() int {
var count int
for _, repo := range me.allrepos {
if repo.Status.IsGoLang() {
count += 1
}
}
return count
}
func (rr *RepoRow) MakeRedoMod() error { func (rr *RepoRow) MakeRedoMod() error {
_, err := rr.pb.RedoGoMod() _, err := rr.pb.RedoGoMod()
return err return err
@ -206,18 +194,17 @@ func (rl *RepoList) MakeGoWork() error {
for _, k := range keys { for _, k := range keys {
repo := rl.allrepos[k] repo := rl.allrepos[k]
if repo.Status.GoPath() == "" { if repo.pb.GoPath == "" {
// skip repos that aren't go // skip repos that aren't go
// todo: handle non-flat repos? // todo: handle non-flat repos?
log.Info("SKIPPED REPO", repo.Status.Path()) log.Info("SKIPPED REPO", repo.pb.GoPath)
continue continue
} }
if repo.Status.Exists("go.mod") { if repo.pb.Exists("go.mod") {
fmt.Fprintln(f, "\t"+repo.Status.GoPath()) fmt.Fprintln(f, "\t"+repo.pb.GoPath)
log.Info("ADDING REPO", goSrcDir, repo.Status.GoPath()) log.Info("ADDING REPO", goSrcDir, repo.pb.GoPath)
} else { } else {
log.Log(REPO, "missing go.mod for", repo.Status.Path()) log.Log(REPO, "missing go.mod for", repo.pb.GoPath)
// repo.Status.MakeRedomod()
} }
} }
fmt.Fprintln(f, ")") fmt.Fprintln(f, ")")