diff options
Diffstat (limited to 'forgeDir.go')
| -rw-r--r-- | forgeDir.go | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/forgeDir.go b/forgeDir.go index 7d5a2a5..43a3c1a 100644 --- a/forgeDir.go +++ b/forgeDir.go @@ -11,15 +11,16 @@ import ( func readGitPB(fullpath string) (*gitpb.Repo, error) { // fmt.Fprintln(w, "repo:", repo.FullPath, repo.Namespace) - bytes, err := os.ReadFile(filepath.Join(fullpath, "git.pb")) + gitfile := filepath.Join(fullpath, "git.pb") + bytes, err := os.ReadFile(gitfile) if err != nil { - log.Info("todo: git.pb non-existant:", fullpath) + log.Info("todo: git.pb non-existant:", gitfile) return nil, err } newr := new(gitpb.Repo) if err := newr.Unmarshal(bytes); err != nil { - log.Info("todo: unmarshal failed for git.pb:", fullpath) - return nil, fmt.Errorf("todo: generate git.pb for " + fullpath) + log.Info("unmarshal failed: NEED TO DELETE:", gitfile) + return nil, fmt.Errorf("todo: re-generate git.pb for " + fullpath) } return newr, nil } @@ -32,12 +33,12 @@ func scanForgedDir(srcDir string) ([]string, error) { err := filepath.WalkDir(srcDir, func(path string, d os.DirEntry, err error) error { if err != nil { // Handle possible errors, like permission issues - fmt.Fprintf(os.Stderr, "error accessing path %q: %v\n", path, err) + log.Infof("error accessing path %q: %v\n", path, err) return err } if d.IsDir() { - // log.Info("path is dir", path) + // log.Info("WHAT IS THIS?", path) } else { _, fname := filepath.Split(path) switch fname { @@ -56,12 +57,27 @@ func scanForgedDir(srcDir string) ([]string, error) { return nil } - gitdir := filepath.Join(path, "git.pb") - _, err2 := os.Stat(gitdir) + gitfile := filepath.Join(path, "git.pb") + _, err2 := os.Stat(gitfile) if !os.IsNotExist(err2) { - all = append(all, path) + log.Info("IS THIS THE ONE?", path) + if ok, err := addGitRepoDir(path); ok { + log.Info("added", path) + } else { + log.Info("err", path, err) + } return filepath.SkipDir } + // log.Info("BAD ?", path) + // all = append(all, path) + + /* + if ok, err := addGitRepoDir(path); ok { + log.Info("added", path) + } else { + log.Info("err", path, err) + } + */ // todo: check if dir is empty here and delete dir? return nil }) |
