From 4b83d18db4fd84de5fa06cc00fe45d74d0feb458 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 2 Dec 2024 05:15:39 -0600 Subject: notsure --- repo.protofiles.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'repo.protofiles.go') diff --git a/repo.protofiles.go b/repo.protofiles.go index eff0d82..54f7c7c 100644 --- a/repo.protofiles.go +++ b/repo.protofiles.go @@ -57,6 +57,8 @@ func (repo *Repo) IsProtobuf() (bool, []string, error) { return anyfound, allc, err } +// look for any proto files. do not enter directories +// note: good golang libraries are best done in a single directory func scanForProtobuf(srcDir string) ([]string, []string, error) { var protofiles []string var compiled []string @@ -66,6 +68,11 @@ func scanForProtobuf(srcDir string) ([]string, []string, error) { return err } + // ignore the start dir + if srcDir == path { + return nil + } + if strings.HasSuffix(path, ".proto") { // protofiles = append(protofiles, path) @@ -75,6 +82,10 @@ func scanForProtobuf(srcDir string) ([]string, []string, error) { compiled = append(compiled, path) } + // don't go into any directories + if info.IsDir() { + return filepath.SkipDir + } return nil }) @@ -83,17 +94,26 @@ func scanForProtobuf(srcDir string) ([]string, []string, error) { func (repo *Repo) GetProtoFiles() ([]string, error) { var protofiles []string - err := filepath.Walk(repo.GetFullPath(), func(path string, info os.FileInfo, err error) error { + srcDir := repo.GetFullPath() + err := filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error { if err != nil { log.Log(GITPBWARN, "Error accessing path:", path, err) return err } + // ignore the start dir + if srcDir == path { + return nil + } + if strings.HasSuffix(path, ".proto") { // protofiles = append(protofiles, path) } + if info.IsDir() { + return filepath.SkipDir + } return nil }) -- cgit v1.2.3