summaryrefslogtreecommitdiff
path: root/goSrcScan.go
diff options
context:
space:
mode:
Diffstat (limited to 'goSrcScan.go')
-rw-r--r--goSrcScan.go36
1 files changed, 26 insertions, 10 deletions
diff --git a/goSrcScan.go b/goSrcScan.go
index 83a6442..2287149 100644
--- a/goSrcScan.go
+++ b/goSrcScan.go
@@ -13,26 +13,36 @@ import (
)
func (f *Forge) ScanGoSrc() (bool, error) {
- log.Info("pre dir walk")
dirs, err := gitDirectoriesNew(f.goSrc)
- log.Info("post dir walk", len(dirs))
if err != nil {
return false, err
}
var gopaths []string
for _, dir := range dirs {
+ // log.Info("forge.ScanGoSrc()", dir)
if strings.HasPrefix(dir, f.goSrc) {
gopath := strings.TrimPrefix(dir, f.goSrc)
gopath = strings.Trim(gopath, "/")
+ if r := f.Repos.FindByGoPath(gopath); r != nil {
+ // log.Info("already have", gopath)
+ continue
+ }
gopaths = append(gopaths, gopath)
} else {
log.Log(FORGEPBWARN, "ScanGoSrc() bad:", dir)
return false, errors.New("forgepb.ScanGoSrc() bad dir: " + dir)
}
}
- log.Info("pre rill")
- f.rillScanDirs(gopaths)
+ newcount, err := f.rillScanDirs(gopaths)
+ if err != nil {
+ log.Info("go src dir problem. exit for now?", err)
+ os.Exit(-1)
+ }
+ if newcount != 0 {
+ log.Info("forge go src scan found", newcount, "repos")
+ f.Repos.ConfigSave()
+ }
return true, err
}
@@ -47,6 +57,13 @@ func gitDirectoriesNew(srcDir string) ([]string, error) {
return err
}
+ if d.IsDir() {
+ // log.Info("path is dir", path)
+ } else {
+ log.Info("warning: you have an untracked file:", path)
+ return nil
+ }
+
gitdir := filepath.Join(path, ".git")
_, err2 := os.Stat(gitdir)
if !os.IsNotExist(err2) {
@@ -118,24 +135,23 @@ func rillAddDirs(gopaths []string) {
// rill is awesome. long live rill
// attempt scan with rill
-func (f *Forge) rillScanDirs(gopaths []string) error {
+func (f *Forge) rillScanDirs(gopaths []string) (int, error) {
// Convert a slice of user IDs into a channel
ids := rill.FromSlice(gopaths, nil)
// Read users from the API.
// Concurrency = 20
dirs := rill.Map(ids, 20, func(id string) (*gitpb.Repo, error) {
- return f.Repos.NewGoPath(f.goSrc, id)
+ return f.NewGoPathRepo(id)
})
+ var counter int
// Activate users.
// Concurrency = 10
err := rill.ForEach(dirs, 10, func(repo *gitpb.Repo) error {
- // could do something here
- // fmt.Printf("Repo found : %s\n", repo.GoPath)
- // repo.Run([]string{"git", "pull"})
+ counter += 1
return nil
})
- return err
+ return counter, err
}