summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addRepo.go24
-rw-r--r--new.go26
-rw-r--r--watchdog.go3
3 files changed, 15 insertions, 38 deletions
diff --git a/addRepo.go b/addRepo.go
index a437816..0d99c14 100644
--- a/addRepo.go
+++ b/addRepo.go
@@ -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
}
diff --git a/new.go b/new.go
index f6841c3..237f582 100644
--- a/new.go
+++ b/new.go
@@ -1,8 +1,6 @@
package repolist
import (
- "strings"
-
"go.wit.com/log"
)
@@ -13,18 +11,6 @@ func RemoveFirstElement(slice []string) (string, []string) {
return slice[0], slice[1:] // Return the slice without the first element
}
-// returns path, master branch name, devel branch name, user branch name
-func splitLine(line string) (string, string, string, string) {
- var path, master, devel, user string
- parts := strings.Split(line, " ")
- path, parts = RemoveFirstElement(parts)
- master, parts = RemoveFirstElement(parts)
- devel, parts = RemoveFirstElement(parts)
- user, parts = RemoveFirstElement(parts)
- // path, master, devel, user := strings.Split(line, " ")
- return path, master, devel, user
-}
-
func RepoType() {
for _, repo := range me.allrepos {
switch repo.Status.RepoType() {
@@ -41,15 +27,3 @@ func RepoType() {
}
}
-
-/*
-func myrepolist() []string {
- homeDir, _ := os.UserHomeDir()
- cfgfile := filepath.Join(homeDir, ".config/autotypist")
- content, _ := ioutil.ReadFile(cfgfile)
- out := string(content)
- out = strings.TrimSpace(out)
- lines := strings.Split(out, "\n")
- return lines
-}
-*/
diff --git a/watchdog.go b/watchdog.go
index e1648c7..9b136f4 100644
--- a/watchdog.go
+++ b/watchdog.go
@@ -21,7 +21,7 @@ import (
// the delay, then the scan will run right away, but if
// you check the checkbox twice in 5 seconds, it won't
// rerun until the delay again
-func (r *RepoList) Watchdog() {
+func (r *RepoList) Watchdog(f func()) {
var delay int = 99
var i int = delay
MyTicker(1*time.Second, "newScan()", func() {
@@ -42,6 +42,7 @@ func (r *RepoList) Watchdog() {
}
i = 0
r.ScanRepositories()
+ f()
})
}