diff options
| author | Jeff Carr <[email protected]> | 2024-02-18 07:25:16 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-02-18 07:25:16 -0600 |
| commit | 860981e63d535cfed566ac831fc9fd130b1b03fb (patch) | |
| tree | b3d48461c302de0e598ab237f2fe4d920e4108f1 /addRepo.go | |
| parent | 985c42221758e40b2811bdd61d6941bda63dccc1 (diff) | |
send a function to the watchdog repo scanner
Diffstat (limited to 'addRepo.go')
| -rw-r--r-- | addRepo.go | 24 |
1 files changed, 13 insertions, 11 deletions
@@ -1,7 +1,7 @@ package repolist import ( - "strings" + "errors" "go.wit.com/gui" "go.wit.com/lib/gui/repostatus" @@ -44,32 +44,32 @@ func (r *Repo) Show() { r.hidden = false } -func (r *RepoList) AddRepo(path string, master string, devel string, user string) *Repo { +func (r *RepoList) AddRepo(path string, master string, devel string, user string) (error, *Repo) { return r.addRepo(r.reposgrid, path, master, devel, user) } -func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel string, user string) *Repo { - _, ok := r.allrepos[path] +func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel string, user string) (error, *Repo) { + existingr, ok := r.allrepos[path] if ok { log.Info("addRepo() already had path", path) - return nil + return nil, existingr } // log.Info("addRepo() attempting to add path", path) - rstatus := repostatus.NewRepoStatusWindow(path) + err, rstatus := repostatus.NewRepoStatusWindow(path) if rstatus == nil { - // log.Info("path isn't a repo I can figure out yet", path) + log.Info("add failed. I can figure this out yet", path, err) // probably this isn't downloaded - return nil + return err, nil } newRepo := new(Repo) newRepo.Status = rstatus - path = strings.TrimSuffix(path, "/") // trim any extranous '/' chars put in the config file by the user + // path = strings.TrimSuffix(path, "/") // trim any extranous '/' chars put in the config file by the user if path == "" { // just an empty line in the config file - return nil + return errors.New("you sent a blank path. stop being silly"), nil } newRepo.pLabel = grid.NewLabel(path).SetProgName("path") @@ -82,6 +82,8 @@ func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel str newRepo.endBox = grid.NewHorizontalBox("HBOX") newRepo.endBox.NewButton("Configure", func() { if newRepo.Status == nil { + // this should never happen, but it does happen because I'm not that smart and forget I can nil Status + // for some reason that makes sense in my head. again, I'm not that smart log.Warn("status window wasn't created") return } @@ -135,5 +137,5 @@ func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel str grid.NextRow() r.allrepos[path] = newRepo - return newRepo + return nil, newRepo } |
