summaryrefslogtreecommitdiff
path: root/forgeDir.go
diff options
context:
space:
mode:
Diffstat (limited to 'forgeDir.go')
-rw-r--r--forgeDir.go94
1 files changed, 0 insertions, 94 deletions
diff --git a/forgeDir.go b/forgeDir.go
deleted file mode 100644
index 5dc9ea8..0000000
--- a/forgeDir.go
+++ /dev/null
@@ -1,94 +0,0 @@
-package main
-
-import (
- "fmt"
- "os"
- "path/filepath"
-
- "go.wit.com/lib/protobuf/gitpb"
- "go.wit.com/log"
-)
-
-func readGitPB(fullpath string) (*gitpb.Repo, error) {
- // fmt.Fprintln(w, "repo:", repo.FullPath, repo.Namespace)
- gitfile := filepath.Join(fullpath, "git.pb")
- bytes, err := os.ReadFile(gitfile)
- if err != nil {
- log.Info("todo: git.pb non-existant:", gitfile)
- return nil, err
- }
- newr := new(gitpb.Repo)
- if err := newr.Unmarshal(bytes); err != nil {
- log.Info("unmarshal failed: NEED TO DELETE:", gitfile)
- return nil, fmt.Errorf("todo: re-generate git.pb for " + fullpath)
- }
- return newr, nil
-}
-
-// doesn't enter the directory any further when it finds a .git/
-// not stupid like my old version
-func scanForgedDir(srcDir string) ([]string, error) {
- var all []string
- var trip bool
- err := filepath.WalkDir(srcDir, func(path string, d os.DirEntry, err error) error {
- if err != nil {
- // Handle possible errors, like permission issues
- log.Infof("error accessing path %q: %v\n", path, err)
- return err
- }
-
- if d.IsDir() {
- // log.Info("WHAT IS THIS?", path)
- } else {
- _, fname := filepath.Split(path)
- switch fname {
- case "repos.pb":
- case "git.pb":
- case "go.work.last":
- case "go.work.sum":
- default:
- // todo: figure out a way to do padding for init()
- if trip == false {
- log.Info("WARNING:")
- }
- log.Info("WARNING: you have an untracked file outside of any .git repository:", path)
- trip = true
- }
- return nil
- }
-
- gitfile := filepath.Join(path, "git.pb")
- _, err2 := os.Stat(gitfile)
- if !os.IsNotExist(err2) {
- // log.Info("IS THIS THE ONE?", path)
- if ok, err := addGitRepoDir(path); ok {
- log.Info("added", path)
- } else {
- if err != nil {
- log.Info("add failed", 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
- })
-
- // probably always leave this here forever
- // this check, along with CheckDirty() makes sure you can safely delete ~/go/src or the go.work directory
- // because everything is either checked in or deleted. An important thing to know!
- if trip {
- log.Info("WARNING: junk in", srcDir)
- }
- return all, err
-}