send a function to the watchdog repo scanner
This commit is contained in:
parent
985c422217
commit
860981e63d
24
addRepo.go
24
addRepo.go
|
@ -1,7 +1,7 @@
|
||||||
package repolist
|
package repolist
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"errors"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gui/repostatus"
|
"go.wit.com/lib/gui/repostatus"
|
||||||
|
@ -44,32 +44,32 @@ func (r *Repo) Show() {
|
||||||
r.hidden = false
|
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)
|
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 {
|
func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel string, user string) (error, *Repo) {
|
||||||
_, ok := r.allrepos[path]
|
existingr, ok := r.allrepos[path]
|
||||||
if ok {
|
if ok {
|
||||||
log.Info("addRepo() already had path", path)
|
log.Info("addRepo() already had path", path)
|
||||||
return nil
|
return nil, existingr
|
||||||
}
|
}
|
||||||
// log.Info("addRepo() attempting to add path", path)
|
// log.Info("addRepo() attempting to add path", path)
|
||||||
rstatus := repostatus.NewRepoStatusWindow(path)
|
err, rstatus := repostatus.NewRepoStatusWindow(path)
|
||||||
|
|
||||||
if rstatus == nil {
|
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
|
// probably this isn't downloaded
|
||||||
return nil
|
return err, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
newRepo := new(Repo)
|
newRepo := new(Repo)
|
||||||
newRepo.Status = rstatus
|
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 == "" {
|
if path == "" {
|
||||||
// just an empty line in the config file
|
// 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")
|
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 = grid.NewHorizontalBox("HBOX")
|
||||||
newRepo.endBox.NewButton("Configure", func() {
|
newRepo.endBox.NewButton("Configure", func() {
|
||||||
if newRepo.Status == nil {
|
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")
|
log.Warn("status window wasn't created")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -135,5 +137,5 @@ func (r *RepoList) addRepo(grid *gui.Node, path string, master string, devel str
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
|
|
||||||
r.allrepos[path] = newRepo
|
r.allrepos[path] = newRepo
|
||||||
return newRepo
|
return nil, newRepo
|
||||||
}
|
}
|
||||||
|
|
26
new.go
26
new.go
|
@ -1,8 +1,6 @@
|
||||||
package repolist
|
package repolist
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
|
||||||
|
|
||||||
"go.wit.com/log"
|
"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
|
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() {
|
func RepoType() {
|
||||||
for _, repo := range me.allrepos {
|
for _, repo := range me.allrepos {
|
||||||
switch repo.Status.RepoType() {
|
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
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ import (
|
||||||
// the delay, then the scan will run right away, but if
|
// the delay, then the scan will run right away, but if
|
||||||
// you check the checkbox twice in 5 seconds, it won't
|
// you check the checkbox twice in 5 seconds, it won't
|
||||||
// rerun until the delay again
|
// rerun until the delay again
|
||||||
func (r *RepoList) Watchdog() {
|
func (r *RepoList) Watchdog(f func()) {
|
||||||
var delay int = 99
|
var delay int = 99
|
||||||
var i int = delay
|
var i int = delay
|
||||||
MyTicker(1*time.Second, "newScan()", func() {
|
MyTicker(1*time.Second, "newScan()", func() {
|
||||||
|
@ -42,6 +42,7 @@ func (r *RepoList) Watchdog() {
|
||||||
}
|
}
|
||||||
i = 0
|
i = 0
|
||||||
r.ScanRepositories()
|
r.ScanRepositories()
|
||||||
|
f()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue