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"
"strings"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/lib/gadgets"
"go.wit.com/log"
)
@ -31,30 +32,25 @@ func FindPathOld(path string) *RepoStatus {
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) {
os.Setenv("REPO_WORK_PATH", path)
}
func NewRepoStatusWindow(path string) (error, *RepoStatus) {
path, realpath, goSrcDir, isGoLang, err := guessPaths(path)
if err != nil {
return err, nil
}
// 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 NewRepoStatusWindow(repo *gitpb.Repo) (*RepoStatus, error) {
path := repo.GoPath
goSrcDir := os.Getenv("FORGE_GOSRC")
realpath := repo.FullPath
isGoLang := true
if windowMap[path] == nil {
log.Log(INFO, "NewRepoStatusWindow() adding new", path)
} else {
log.Warn("This already exists for path", path)
log.Warn("should return windowMap[path] here")
return nil, windowMap[path]
return windowMap[path], nil
}
rs := &RepoStatus{
@ -117,5 +113,5 @@ func NewRepoStatusWindow(path string) (error, *RepoStatus) {
rs.goPath.SetText(path)
}
windowMap[path] = rs
return nil, rs
return rs, nil
}