summaryrefslogtreecommitdiff
path: root/common.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-06 20:30:00 -0600
committerJeff Carr <[email protected]>2024-11-06 20:30:00 -0600
commit3ce9f5f77346c0fc94910de266453f3729fd88b6 (patch)
tree3be5d8b18fb4fde8b3c3ca7e097cc9735f24cb53 /common.go
parent44ab5deb3fe859ac09c91f2b06fc20a4710b142f (diff)
find .proto and .pb.go filesv0.22.8
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'common.go')
-rw-r--r--common.go42
1 files changed, 33 insertions, 9 deletions
diff --git a/common.go b/common.go
index 520d12b..6f9ff2f 100644
--- a/common.go
+++ b/common.go
@@ -1,7 +1,9 @@
package repostatus
import (
+ "errors"
"os"
+ "path/filepath"
"strings"
"unicode"
@@ -59,18 +61,40 @@ func (rs *RepoStatus) IsPrimitive() bool {
return false
}
-func (rs *RepoStatus) IsProtobuf() (bool, []string, []string, error) {
+func (rs *RepoStatus) IsProtobuf() (bool, []string, error) {
log.Info("are there .proto files in:", rs.Path())
- all, compiled, err := ScanForProtobuf(rs.Path())
- var found bool = false
- for i, s := range all {
- log.Info("found i, s:", i, s)
- found = true
+ fullp, fullc, err := ScanForProtobuf(rs.Path())
+ protos := make(map[string]string)
+ protoc := make(map[string]string)
+ var anyfound bool = false
+ var allc []string
+ for _, s := range fullp {
+ filebase := filepath.Base(s)
+ name := strings.TrimSuffix(filebase, ".proto")
+ // log.Info("found i, s:", i, name, filebase)
+ anyfound = true
+ protos[name] = s
}
- for i, s := range compiled {
- log.Info("found compiled i, s:", i, s)
+ for pname, _ := range protos {
+ var found bool = false
+ for _, s := range fullc {
+ cfilebase := filepath.Base(s)
+ cname := strings.TrimSuffix(cfilebase, ".pb.go")
+ // log.Info("found compiled i, s:", i, cname, cfilebase)
+ protoc[cname] = s
+ if cname == pname {
+ found = true
+ allc = append(allc, cfilebase)
+ }
+ }
+ if found {
+ // log.Info("found ok")
+ } else {
+ log.Info("not found")
+ err = errors.New("compiled file " + pname + ".pb.go missing")
+ }
}
- return found, all, compiled, err
+ return anyfound, allc, err
}
// returns the filesystem path to the repo