summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.go4
-rw-r--r--doMtime.go (renamed from doClean.go)15
-rw-r--r--main.go9
3 files changed, 15 insertions, 13 deletions
diff --git a/argv.go b/argv.go
index 909df65..c90d486 100644
--- a/argv.go
+++ b/argv.go
@@ -30,8 +30,8 @@ type args struct {
Comments bool `arg:"--format-comments" help:"enforce parseable comments in a .proto file"`
NoFormat bool `arg:"--no-format" help:"do not auto-reformat the .proto file"`
Renumber bool `arg:"--renumber" help:"renumber everything. obviously breaks backwards compatiblity"`
- Clean bool `arg:"--clean" help:"clean out any *pb.go files; bypassing ctime sanity checks"`
- Ctime bool `arg:"--ctime" help:"do os.Stat() createtime sanity checks"`
+ Clean bool `arg:"--clean" help:"clean out any *pb.go files; bypassing mtime sanity checks"`
+ Mtime bool `arg:"--mtime" help:"do os.Stat() modtime sanity checks"`
GoSrc string `arg:"--go-src" help:"default is ~/go/src. could be set to your go.work path"`
GoPath string `arg:"--gopath" help:"the gopath of this repo"`
Identify string `arg:"--identify" help:"identify file"`
diff --git a/doClean.go b/doMtime.go
index d1af455..4f69642 100644
--- a/doClean.go
+++ b/doMtime.go
@@ -17,11 +17,12 @@ import (
"os"
"path/filepath"
+ "go.wit.com/lib/config"
"go.wit.com/log"
)
func doClean(filebase string) error {
- globPattern := filebase + ".*.pb.go"
+ globPattern := filebase + "*.pb.go"
files, err := filepath.Glob(globPattern)
if err != nil {
log.Info("glob error", err, files)
@@ -35,12 +36,12 @@ func doClean(filebase string) error {
}
// is true if no errors and nothing is new
-func doCtime(filebase string) bool {
+func doMtime(filebase string) bool {
var allerr error
statf, err := os.Stat(filebase + ".proto")
allerr = errors.Join(allerr, err)
basetime := statf.ModTime()
- globPattern := filebase + ".*.pb.go"
+ globPattern := filebase + "*.pb.go"
files, err := filepath.Glob(globPattern)
if err != nil {
log.Info("glob error", err, files)
@@ -63,15 +64,17 @@ func doCtime(filebase string) bool {
err := doClean(filebase)
allerr = errors.Join(allerr, err)
if allerr != nil {
- log.Info("autogenpb doCtime() had errors:", allerr)
+ log.Info("autogenpb doMtime() had errors:", allerr)
}
return false
}
}
- log.Info(filebase + ".proto was older than all pb.go files. No need to re-run autogenpb.")
+ if config.Verbose() {
+ log.Info(filebase + ".proto was older than all pb.go files. No need to re-run autogenpb.")
+ }
if allerr == nil {
return true
}
- log.Info("autogenpb doCtime() had errors:", allerr)
+ log.Info("autogenpb doMtime() had errors:", allerr)
return false
}
diff --git a/main.go b/main.go
index 8f97dd8..485be83 100644
--- a/main.go
+++ b/main.go
@@ -77,8 +77,8 @@ func doProto(argvProto string) error {
me.sh.GoodExit("doClean() ran")
}
- if argv.Ctime {
- doCtime(pf.Filebase)
+ if argv.Mtime {
+ doMtime(pf.Filebase)
me.sh.GoodExit("doClean() ran")
}
@@ -100,9 +100,8 @@ func doProto(argvProto string) error {
os.Setenv("PROTOBUF_REGRET", "true")
}
- if doCtime(pf.Filebase) {
- log.Info("nothing changed. exit here")
- me.sh.GoodExit("doCtime() ran")
+ if doMtime(pf.Filebase) {
+ me.sh.GoodExit(pf.Filename + " did not change")
} else {
log.Info("ctime check: need to re-run autogenpb")
}