diff options
| -rw-r--r-- | argv.go | 3 | ||||
| -rw-r--r-- | handleRepos.go | 10 | ||||
| -rw-r--r-- | main.go | 27 | ||||
| -rw-r--r-- | structs.go | 2 |
4 files changed, 39 insertions, 3 deletions
@@ -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 } @@ -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) @@ -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 } |
