find .proto and .pb.go files
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
44ab5deb3f
commit
3ce9f5f773
38
common.go
38
common.go
|
@ -1,7 +1,9 @@
|
||||||
package repostatus
|
package repostatus
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
|
@ -59,18 +61,40 @@ func (rs *RepoStatus) IsPrimitive() bool {
|
||||||
return false
|
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())
|
log.Info("are there .proto files in:", rs.Path())
|
||||||
all, compiled, err := ScanForProtobuf(rs.Path())
|
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 pname, _ := range protos {
|
||||||
var found bool = false
|
var found bool = false
|
||||||
for i, s := range all {
|
for _, s := range fullc {
|
||||||
log.Info("found i, s:", i, s)
|
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
|
found = true
|
||||||
|
allc = append(allc, cfilebase)
|
||||||
}
|
}
|
||||||
for i, s := range compiled {
|
|
||||||
log.Info("found compiled i, s:", i, s)
|
|
||||||
}
|
}
|
||||||
return found, all, compiled, err
|
if found {
|
||||||
|
// log.Info("found ok")
|
||||||
|
} else {
|
||||||
|
log.Info("not found")
|
||||||
|
err = errors.New("compiled file " + pname + ".pb.go missing")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return anyfound, allc, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the filesystem path to the repo
|
// returns the filesystem path to the repo
|
||||||
|
|
Loading…
Reference in New Issue