From e6f883a9b5e62cb5d52e5c2dbc37d3d15db11b12 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 5 Nov 2024 05:58:54 -0600 Subject: [PATCH] final commits before release Signed-off-by: Jeff Carr --- common.go | 9 +++++++++ structs.go | 10 ++++++---- unix.go | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) 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 +}