diff options
| author | Jeff Carr <[email protected]> | 2024-12-02 05:15:39 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-12-02 05:15:39 -0600 |
| commit | 4b83d18db4fd84de5fa06cc00fe45d74d0feb458 (patch) | |
| tree | 158ca0bdf4aa81d06fb27850299e1c3be1882984 /repo.protofiles.go | |
| parent | 425cb042b997e9243ea19ea82bfaa9ccce484a5c (diff) | |
notsurev0.0.18
Diffstat (limited to 'repo.protofiles.go')
| -rw-r--r-- | repo.protofiles.go | 22 |
1 files changed, 21 insertions, 1 deletions
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 }) |
