diff --git a/.protobuf b/.protobuf new file mode 100644 index 0000000..a26df76 --- /dev/null +++ b/.protobuf @@ -0,0 +1,3 @@ +gitTag.proto +goDep.proto +repo.proto diff --git a/goDep.redoGoMod.go b/goDep.redoGoMod.go index 91cad2f..1313039 100644 --- a/goDep.redoGoMod.go +++ b/goDep.redoGoMod.go @@ -40,7 +40,7 @@ func (repo *Repo) RedoGoMod() (bool, error) { if repo.Exists("go.sum") { // return the attempt to parse go.mod & go.sum - return repo.parseGoSum() + return repo.ParseGoSum() } repo.GoDeps = new(GoDeps) repo.GoPrimitive = false @@ -61,7 +61,8 @@ func (repo *Repo) RedoGoMod() (bool, error) { } // reads and parses the go.sum file -func (repo *Repo) parseGoSum() (bool, error) { +// does not change anything +func (repo *Repo) ParseGoSum() (bool, error) { // empty out what was there before repo.GoDeps = nil tmp := filepath.Join(repo.FullPath, "go.sum") 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 })