From 5b277e7686974d2195586d5f5b82838ee9ddb036 Mon Sep 17 00:00:00 2001 From: forge Date: Mon, 6 Oct 2025 12:17:14 -0500 Subject: working on ping pong --- argv.go | 3 ++- handleRepos.go | 10 ++++++++-- main.go | 27 +++++++++++++++++++++++++++ structs.go | 2 ++ 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/argv.go b/argv.go index 6e1783e..d73dbc0 100644 --- a/argv.go +++ b/argv.go @@ -22,6 +22,7 @@ type args struct { Repos *ReposCmd `arg:"subcommand:repos" help:"the forged repos"` Patch *PatchCmd `arg:"subcommand:patches" help:"the forged patches"` Gui *EmptyCmd `arg:"subcommand:gui" help:"show gui"` + Missing *EmptyCmd `arg:"subcommand:missing" help:"list missing repos"` Port int `arg:"--port" default:"2520" help:"port to run on"` Hostname string `arg:"--hostname" help:"hostname to use"` Daemon bool `arg:"--daemon" help:"run as a daemon"` @@ -97,7 +98,7 @@ func (args) Version() string { func (a args) DoAutoComplete(pb *prep.Auto) { if pb.Cmd == "" { - pb.Autocomplete3([]string{"--bash", "repos", "gui", "patches", "--daemon"}) + pb.Autocomplete3([]string{"--bash", "repos", "gui", "patches", "--daemon", "missing"}) } else { pb.SubCommand(pb.Argv...) } diff --git a/handleRepos.go b/handleRepos.go index ac28c7f..5a1f07f 100644 --- a/handleRepos.go +++ b/handleRepos.go @@ -64,9 +64,14 @@ func addRequest(pb *gitpb.Repos, reqPB *httppb.HttpRequest) *gitpb.Repos { func checkRequest(pb *gitpb.Repos, reqPB *httppb.HttpRequest) *gitpb.Repos { checkPB := gitpb.NewRepos() for repo := range pb.IterAll() { - found := me.forge.PrepareCheckRepo(repo.Namespace) + // found := me.forge.PrepareCheckRepo(repo.Namespace) + found := me.forge.Repos.FindByNamespace(repo.Namespace) if found == nil { - // don't know about this + if me.missing == nil { + continue + } + // new missing repo + me.missing.AppendByNamespace(repo) continue } if found.GetURL() != repo.GetURL() { @@ -74,6 +79,7 @@ func checkRequest(pb *gitpb.Repos, reqPB *httppb.HttpRequest) *gitpb.Repos { } checkPB.Append(found) } + saveMissing() return checkPB } diff --git a/main.go b/main.go index 00e508c..e78bae6 100644 --- a/main.go +++ b/main.go @@ -2,12 +2,16 @@ package main import ( "embed" + "errors" "fmt" "net/http" + "os" + "path/filepath" "time" "go.wit.com/lib/gui/prep" "go.wit.com/lib/protobuf/forgepb" + "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) @@ -21,6 +25,14 @@ var resources embed.FS var HOSTNAME string = "forge.wit.com" +func saveMissing() error { + err := me.missing.Save(filepath.Join(me.forge.Config.ReposDir, "missing.pb")) + if err != nil { + log.Info("failed to save missing.pb", err) + } + return err +} + func main() { me = new(mainType) me.myGui = prep.Gui() // prepares the GUI package for go-args @@ -41,6 +53,21 @@ func main() { okExit("") } + me.missing = gitpb.NewRepos() + err := me.missing.ConfigLoad(filepath.Join(me.forge.Config.ReposDir, "missing.pb")) + if errors.Is(err, os.ErrNotExist) { + saveMissing() + } else if err != nil { + log.Info("loading missing.pb failed", err) + badExit(err) + } + + if argv.Missing != nil { + log.Info("loading missing.pb worked len =", me.missing.Len()) + me.missing.PrintMissingTable() + okExit("") + } + if argv.Repos != nil { if err := doRepos(); err != nil { badExit(err) diff --git a/structs.go b/structs.go index 22f5b01..556a239 100644 --- a/structs.go +++ b/structs.go @@ -7,6 +7,7 @@ import ( "go.wit.com/dev/alexflint/arg" "go.wit.com/lib/gui/prep" "go.wit.com/lib/protobuf/forgepb" + "go.wit.com/lib/protobuf/gitpb" ) var me *mainType @@ -18,4 +19,5 @@ type mainType struct { myGui *prep.GuiPrep // the gui toolkit handle auto *prep.Auto // more experiments for bash handling configs *forgepb.ForgeConfigs // for holding the forge protobuf files + missing *gitpb.Repos // repos we are missing } -- cgit v1.2.3