start refactor to protobuf

This commit is contained in:
Jeff Carr 2024-11-28 18:36:29 -06:00
parent 9d13c972e4
commit e43863e8e7
1 changed files with 11 additions and 15 deletions

26
new.go
View File

@ -4,6 +4,7 @@ import (
"os" "os"
"strings" "strings"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/lib/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/log" "go.wit.com/log"
) )
@ -31,30 +32,25 @@ func FindPathOld(path string) *RepoStatus {
return windowMap[path] return windowMap[path]
} }
// makes a window of the status of the repo
// don't worry, you can think of it like Sierpinski carpet
// it's doesn't need to be displayed so it'll work fine even in an embedded space
func New(path string) (*RepoStatus, error) {
err, r := NewRepoStatusWindow(path)
return r, err
}
func SetWorkPath(path string) { func SetWorkPath(path string) {
os.Setenv("REPO_WORK_PATH", path) os.Setenv("REPO_WORK_PATH", path)
} }
func NewRepoStatusWindow(path string) (error, *RepoStatus) { // makes a window of the status of the repo
path, realpath, goSrcDir, isGoLang, err := guessPaths(path) // don't worry, you can think of it like Sierpinski carpet
if err != nil { // it's doesn't need to be displayed so it'll work fine even in an embedded space
return err, nil func NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
} path := repo.GoPath
goSrcDir := os.Getenv("FORGE_GOSRC")
realpath := repo.FullPath
isGoLang := true
if windowMap[path] == nil { if windowMap[path] == nil {
log.Log(INFO, "NewRepoStatusWindow() adding new", path) log.Log(INFO, "NewRepoStatusWindow() adding new", path)
} else { } else {
log.Warn("This already exists for path", path) log.Warn("This already exists for path", path)
log.Warn("should return windowMap[path] here") log.Warn("should return windowMap[path] here")
return nil, windowMap[path] return windowMap[path], nil
} }
rs := &RepoStatus{ rs := &RepoStatus{
@ -117,5 +113,5 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
rs.goPath.SetText(path) rs.goPath.SetText(path)
} }
windowMap[path] = rs windowMap[path] = rs
return nil, rs return rs, nil
} }