diff --git a/common.go b/common.go index bd1cc60..8895542 100644 --- a/common.go +++ b/common.go @@ -59,6 +59,15 @@ func (rs *RepoStatus) IsPrimitive() bool { return false } +func (rs *RepoStatus) IsProtobuf() (bool, []string, error) { + log.Info("are there .proto files in:", rs.Path()) + all, err := ScanForProtobuf(rs.Path()) + for i, s := range all { + log.Info("found i, s:", i, s) + } + return false, all, err +} + // returns the filesystem path to the repo func (rs *RepoStatus) Path() string { return rs.realPath.String() diff --git a/structs.go b/structs.go index e9916b5..e30119e 100644 --- a/structs.go +++ b/structs.go @@ -10,7 +10,7 @@ type RepoStatus struct { changed bool // keeps track of changes that might have happened changes string tags map[string]string - InitOk bool // it takes a second or so to init these + InitOk bool // it takes a second or so to init these // used to temporarily tell the automation tools to // try to ignore this repo's changes and state @@ -23,11 +23,13 @@ type RepoStatus struct { Tags *GitTagBox // a box of all the git tags dirtyLabel *gadgets.OneLiner - dirtyList string // the output from git status --porcelain + dirtyList string // the output from git status --porcelain readOnly *gadgets.OneLiner gitState *gadgets.OneLiner - primitive *gadgets.OneLiner - private *gadgets.OneLiner + + primitive *gadgets.OneLiner // aka: doesn't have a go.sum file + private *gadgets.OneLiner // it's not possible to publish this to pkg.go.dev + protobuf *gadgets.OneLiner // is this repo a protobuf repo? path *gadgets.OneLiner goSrcPath *gadgets.OneLiner diff --git a/unix.go b/unix.go index 1929d24..6d90676 100644 --- a/unix.go +++ b/unix.go @@ -466,3 +466,22 @@ func ScanGitDirectories(srcDir string) []string { return all } + +func ScanForProtobuf(srcDir string) ([]string, error) { + var protofiles []string + err := filepath.Walk(srcDir, func(path string, info os.FileInfo, err error) error { + if err != nil { + log.Log(REPOWARN, "Error accessing path:", path, err) + return err + } + + if strings.HasSuffix(path, ".proto") { + // + protofiles = append(protofiles, path) + } + + return nil + }) + + return protofiles, err +}