From 73756cf5fa8d9853f06f94c49b3657aed6cdb947 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 3 Dec 2024 18:03:09 -0600 Subject: [PATCH] more moving to protobuf --- common.go | 47 +++++++++++++++++------------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) diff --git a/common.go b/common.go index 0992341..b5ec143 100644 --- a/common.go +++ b/common.go @@ -8,7 +8,6 @@ import ( "github.com/go-cmd/cmd" "go.wit.com/gui" - "go.wit.com/lib/gui/repostatus" "go.wit.com/log" ) @@ -34,7 +33,7 @@ func (r *RepoList) FindByName(name string) *RepoRow { loop := r.ReposSortByName() for loop.Scan() { repo := loop.Repo() - if repo.GoPath() == name { + if repo.pb.GoPath == name { return repo } base := filepath.Base(repo.GoPath()) @@ -85,22 +84,19 @@ func (r *RepoRow) Scan() int { // returns a name for human consuption only // todo: implement nicknames func (rs *RepoRow) Name() string { - if rs.Status.IsGoLang() { - return rs.Status.GoPath() - } - return rs.Status.Path() + return rs.pb.GoPath } func (r *RepoRow) GoPath() string { - return r.Status.GoPath() + return r.pb.GoPath } func (r *RepoRow) CheckDirty() bool { - return r.Status.CheckDirty() + return r.pb.CheckDirty() } func (r *RepoRow) IsDirty() bool { - return r.Status.IsDirty() + return r.pb.IsDirty() } func (r *RepoRow) RepoType() string { @@ -112,11 +108,11 @@ func (r *RepoRow) ReadOnly() bool { log.Warn("ReadOnly() repo == nil") return false } - if r.Status == nil { - log.Warn("ReadOnly() repo.Status == nil") + if r.pb == nil { + log.Warn("ReadOnly() repo.pb == nil") return false } - return r.Status.ReadOnly() + return r.pb.ReadOnly } func (r *RepoRow) LastTag() string { @@ -138,9 +134,10 @@ func (r *RepoRow) IsPerfect() bool { } func (r *RepoRow) Run(cmd []string) cmd.Status { - return r.Status.Run(cmd) + return r.pb.Run(cmd) } +/* func (r *RepoRow) AllTags() []*repostatus.Tag { return r.Status.Tags.ListAll() } @@ -154,6 +151,7 @@ func (r *RepoRow) DeleteTag(t *repostatus.Tag) bool { r.Status.DeleteTag(t) return true } +*/ func (rl *RepoList) MirrorShownCount() *gui.Node { return gui.RawMirror(rl.shownCount) @@ -167,16 +165,6 @@ func (rl *RepoList) Total() int { 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 { _, err := rr.pb.RedoGoMod() return err @@ -206,18 +194,17 @@ func (rl *RepoList) MakeGoWork() error { for _, k := range keys { repo := rl.allrepos[k] - if repo.Status.GoPath() == "" { + if repo.pb.GoPath == "" { // skip repos that aren't go // todo: handle non-flat repos? - log.Info("SKIPPED REPO", repo.Status.Path()) + log.Info("SKIPPED REPO", repo.pb.GoPath) continue } - if repo.Status.Exists("go.mod") { - fmt.Fprintln(f, "\t"+repo.Status.GoPath()) - log.Info("ADDING REPO", goSrcDir, repo.Status.GoPath()) + if repo.pb.Exists("go.mod") { + fmt.Fprintln(f, "\t"+repo.pb.GoPath) + log.Info("ADDING REPO", goSrcDir, repo.pb.GoPath) } else { - log.Log(REPO, "missing go.mod for", repo.Status.Path()) - // repo.Status.MakeRedomod() + log.Log(REPO, "missing go.mod for", repo.pb.GoPath) } } fmt.Fprintln(f, ")")