summaryrefslogtreecommitdiff
path: root/scanRepoDir.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-13 08:31:54 -0500
committerJeff Carr <[email protected]>2025-09-13 08:31:54 -0500
commitcb6394f34a250aed6cb186bd2a9af39d8c19f5f4 (patch)
tree37eadbb71aea7b121760062f14a0938e44e921f4 /scanRepoDir.go
parent2fccf603358f5c7e3f3403c1ca5e7f50451d88fd (diff)
finally dump this old code
Diffstat (limited to 'scanRepoDir.go')
-rw-r--r--scanRepoDir.go61
1 files changed, 61 insertions, 0 deletions
diff --git a/scanRepoDir.go b/scanRepoDir.go
index 6459ce0..258d3dc 100644
--- a/scanRepoDir.go
+++ b/scanRepoDir.go
@@ -1,6 +1,10 @@
package forgepb
import (
+ "fmt"
+ "os"
+ "path/filepath"
+
"github.com/destel/rill"
"go.wit.com/lib/config"
"go.wit.com/lib/protobuf/gitpb"
@@ -108,3 +112,60 @@ func (f *Forge) rillScanDirsNew(fullpaths []string) (int, error) {
return counter, err
}
+
+// doesn't enter the directory any further when it finds a .git/
+// not stupid like my old version
+func gitDirectoriesNew(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
+ fmt.Fprintf(os.Stderr, "error accessing path %q: %v\n", path, err)
+ return err
+ }
+
+ if d.IsDir() {
+ // log.Info("path is dir", path)
+ } else {
+ _, fname := filepath.Split(path)
+ switch fname {
+ case "repos.pb":
+ case "go.work":
+ 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
+ }
+
+ gitdir := filepath.Join(path, ".git")
+ _, err2 := os.Stat(gitdir)
+ if !os.IsNotExist(err2) {
+ all = append(all, path)
+ return filepath.SkipDir
+ }
+ 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:")
+ log.Info("WARNING: there isn't a way to disable this warning yet")
+ log.Info("WARNING: probably this is a good thing however. you don't want to leave files outside of git repos here")
+ log.Info("WARNING: so this warning should probably stay")
+ log.Info("WARNING:")
+ log.Info("WARNING: this also might mean you put these files here because you are actively working on them")
+ log.Info("WARNING: and you don't want to forget about them")
+ log.Info("WARNING:")
+ }
+ return all, err
+}