From f540aab43407a50477c8b25af8ba125dcc5c6be6 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 22 Feb 2025 06:53:42 -0600 Subject: [PATCH] remove zoopb from forge --- http.go | 18 ++++++++++-------- init.go | 40 ++++++++++++++++++++++------------------ patchset.Make.go | 4 ++-- structs.go | 23 +++++++++++------------ 4 files changed, 45 insertions(+), 40 deletions(-) diff --git a/http.go b/http.go index a7edf51..dbc0cb0 100644 --- a/http.go +++ b/http.go @@ -4,15 +4,14 @@ package forgepb import ( "bytes" - "fmt" "io/ioutil" "net/http" "os/user" - "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) +/* func (f *Forge) HttpPostMachine(url string) ([]byte, error) { if f.Machine == nil { // run f.InitMachine() here? @@ -40,6 +39,7 @@ func (f *Forge) HttpPostMachine(url string) ([]byte, error) { log.Info("good? check.hostname =", check.Hostname) return f.HttpPost(url, msg) } +*/ func (f *Forge) HttpPost(url string, data []byte) ([]byte, error) { var err error @@ -50,12 +50,14 @@ func (f *Forge) HttpPost(url string, data []byte) ([]byte, error) { usr, _ := user.Current() req.Header.Set("author", usr.Username) - if f.Machine == nil { - // run f.InitMachine() here? - log.Info("you must run f.InitMachine()") - return nil, fmt.Errorf("you must run f.InitMachine()") - } - req.Header.Set("hostname", f.Machine.Hostname) + /* + if f.Machine == nil { + // run f.InitMachine() here? + log.Info("you must run f.InitMachine()") + return nil, fmt.Errorf("you must run f.InitMachine()") + } + */ + req.Header.Set("hostname", "fixme:hostname") client := &http.Client{} resp, err := client.Do(req) diff --git a/init.go b/init.go index 2da1427..cf53d88 100644 --- a/init.go +++ b/init.go @@ -6,12 +6,10 @@ import ( "os" "os/user" "path/filepath" - "strings" "time" "go.wit.com/lib/gui/shell" "go.wit.com/lib/protobuf/gitpb" - "go.wit.com/lib/protobuf/zoopb" "go.wit.com/log" ) @@ -21,10 +19,12 @@ import ( func Init() *Forge { f := InitPB() - f.Machine = new(zoopb.Machine) - if err := f.Machine.ConfigLoad(); err != nil { - log.Log(WARN, "zoopb.ConfigLoad() failed", err) - } + /* + f.Machine = new(zoopb.Machine) + if err := f.Machine.ConfigLoad(); err != nil { + log.Log(WARN, "zoopb.ConfigLoad() failed", err) + } + */ if f.Config.Username == "" { usr, _ := user.Current() f.Config.Username = usr.Username @@ -40,7 +40,7 @@ func Init() *Forge { f.SetConfigSave(true) } - f.Machine.InitWit() + // f.Machine.InitWit() if f.hasFullScan { // duplicate time checking below. which one to keep? @@ -135,24 +135,28 @@ func (f *Forge) InitPB() { } func (f *Forge) InitMachine() { - f.Machine = new(zoopb.Machine) - if err := f.Machine.ConfigLoad(); err != nil { - log.Log(WARN, "zoopb.ConfigLoad() failed", err) - f.Machine.InitWit() - } + /* + f.Machine = new(zoopb.Machine) + if err := f.Machine.ConfigLoad(); err != nil { + log.Log(WARN, "zoopb.ConfigLoad() failed", err) + f.Machine.InitWit() + } + */ if f.Config.Username == "" { usr, _ := user.Current() f.Config.Username = usr.Username } - if f.Machine.Hostname == "" { - r, err := shell.RunVerbose([]string{"hostname", "-f"}) - if err == nil { - tmp := strings.Join(r.Stdout, "\n") - f.Machine.Hostname = strings.TrimSpace(tmp) + /* + if f.Machine.Hostname == "" { + r, err := shell.RunVerbose([]string{"hostname", "-f"}) + if err == nil { + tmp := strings.Join(r.Stdout, "\n") + f.Machine.Hostname = strings.TrimSpace(tmp) + } } - } + */ } // only init's the protobuf. intended to not scan or change anything diff --git a/patchset.Make.go b/patchset.Make.go index 54f9a8a..4368719 100644 --- a/patchset.Make.go +++ b/patchset.Make.go @@ -43,11 +43,11 @@ func (f *Forge) MakeDevelPatchSet(name string) (*Patchset, error) { for all.Scan() { repo := all.Next() - if ! repo.IsLocalBranch(repo.GetUserBranchName()) { + if !repo.IsLocalBranch(repo.GetUserBranchName()) { // log.Info("repo doesn't have user branch", repo.GetGoPath()) continue } - if ! repo.IsLocalBranch(repo.GetDevelBranchName()) { + if !repo.IsLocalBranch(repo.GetDevelBranchName()) { // log.Info("repo doesn't have devel branch", repo.GetGoPath()) continue } diff --git a/structs.go b/structs.go index a69c2c5..6682f87 100644 --- a/structs.go +++ b/structs.go @@ -5,23 +5,22 @@ import ( "time" "go.wit.com/lib/protobuf/gitpb" - "go.wit.com/lib/protobuf/zoopb" ) // maybe an interface someday? type Forge struct { // one-time initialized data - initOnce sync.Once - initErr error // init error, if any - goSrc string // the path to go/src - configDir string // normally ~/.config/forge - goWork bool // means the user is currently using a go.work file - Config *ForgeConfigs // config repos for readonly, private, etc - Repos *gitpb.Repos // the repo protobufs - Machine *zoopb.Machine // things for virtigo to track vm's - configSave bool // if you need to save the config because things changed - hasFullScan bool // track last scan so it can be throttled - fullscan time.Time // time of the last scan so it can be throttled + initOnce sync.Once + initErr error // init error, if any + goSrc string // the path to go/src + configDir string // normally ~/.config/forge + goWork bool // means the user is currently using a go.work file + Config *ForgeConfigs // config repos for readonly, private, etc + Repos *gitpb.Repos // the repo protobufs + // Machine *zoopb.Machine // things for virtigo to track vm's + configSave bool // if you need to save the config because things changed + hasFullScan bool // track last scan so it can be throttled + fullscan time.Time // time of the last scan so it can be throttled } func (f *Forge) GetGoSrc() string {