diff options
| author | Jeff Carr <[email protected]> | 2024-12-03 00:35:33 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-03 00:35:33 -0600 |
| commit | cbdcfa05894636001e5f2a60c6ea70c1f715c0fc (patch) | |
| tree | fc5e5e731d667cf3406329029375f0fa554e8b50 /goSrcScan.go | |
| parent | 189d305feeab86df88f2749afb959aa382154716 (diff) | |
fixing Init()
Diffstat (limited to 'goSrcScan.go')
| -rw-r--r-- | goSrcScan.go | 36 |
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 } |
