]> Cypherpunks.ru repositories - goredo.git/commitdiff
REDO_STOP_IF_MODIFIED
authorSergey Matveev <stargrave@stargrave.org>
Wed, 26 Jan 2022 13:51:44 +0000 (16:51 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 26 Jan 2022 14:02:49 +0000 (17:02 +0300)
doc/cmds.texi
doc/features.texi
doc/news.texi
main.go
run.go

index b4e7bf575c99413ef7c67df4f9c8a90c3f938114..de8d374f1cc9934a9df23a9362fd217b2bb79e01 100644 (file)
@@ -46,6 +46,13 @@ By default all build commands use @code{fsync} to assure data is reached
 the disk. You can disable its usage with @env{$REDO_NO_SYNC=1}
 environment variable, for speeding up the build process.
 
+If redo sees some target modified externally, then by default it warns
+user about that, does not build that target, but continues the build
+process further. That is convenient in most cases: you can build your
+project with manual targets alterings, without touching possibly more
+complicated @file{.do} files. With @env{$REDO_STOP_IF_MODIFIED=1} redo
+won't continue and will exit with failure message.
+
 There are other commands that could be found in other implementations too:
 
 @table @command
index 13530aec4502f43def54f4d2c8002564ae92f58b..4d0364b31fff03927a9b86327b150bf9e139aaf3 100644 (file)
@@ -12,6 +12,7 @@ implementations.
     @item check that @file{stdout} and @file{$3} are not written simultaneously
     @item check that generated target was not modified "externally" outside
       the redo, preventing its overwriting, but continuing the build
+      (optionally can stop)
     @end itemize
 @item recursive, indented and serialized logs display ability, with
     priority to the depth and bad return codes, like in @command{apenwarr/redo},
index 69ba830e1b7c92736f3c87ed6dda3b51cc58bfe2..1dbdb859919482e084537ec75fcab612dae425d3 100644 (file)
     corresponding targets has the same content but different
     @code{ctime}/@code{mtime} values and rewrites dependencies with that
     updated inode information.
+@item
+    With @env{$REDO_STOP_IF_MODIFIED=1} environment variable redo will
+    stop and fail if it meet externally modified file. By default user
+    is only warned about it, but building continues for convenience.
 @end itemize
 
 @anchor{Release 1_21_0}
diff --git a/main.go b/main.go
index 63de9315f942dd96e5cbfdb3147daba8fd880ed7..f75edd4049a69d8cd50ca6fee27d5c8f64e36ff2 100644 (file)
--- a/main.go
+++ b/main.go
@@ -198,6 +198,7 @@ func main() {
        }
        NoColor = os.Getenv(EnvNoColor) != ""
        NoSync = os.Getenv(EnvNoSync) == "1"
+       StopIfMod = os.Getenv(EnvStopIfMod) == "1"
        switch s := os.Getenv(EnvInodeTrust); s {
        case "none":
                InodeTrust = InodeTrustNone
diff --git a/run.go b/run.go
index 6366f4a0aad03c79272acf524a0cd8d8972843de..ba841522835e50dad65a5523ff5fe6c4d545ad8c 100644 (file)
--- a/run.go
+++ b/run.go
@@ -51,6 +51,7 @@ const (
        EnvStderrKeep   = "REDO_LOGS"
        EnvStderrSilent = "REDO_SILENT"
        EnvNoSync       = "REDO_NO_SYNC"
+       EnvStopIfMod    = "REDO_STOP_IF_MODIFIED"
 
        RedoDir      = ".redo"
        LockSuffix   = ".lock"
@@ -65,6 +66,7 @@ var (
        StderrKeep   = false
        StderrSilent = false
        StderrPrefix string
+       StopIfMod    = false
        Jobs         sync.WaitGroup
 
        flagTrace        *bool
@@ -273,8 +275,11 @@ func runScript(tgtOrig string, errs chan error, traced bool) error {
                return TgtError{tgtOrig, err}
        }
        if modified {
-               tracef(CWarn, "%s externally modified: not redoing", tgtOrig)
                lockRelease()
+               if StopIfMod {
+                       return fmt.Errorf("%s externally modified", tgtOrig)
+               }
+               tracef(CWarn, "%s externally modified: not redoing", tgtOrig)
                go func() {
                        errs <- nil
                }()