From: Sergey Matveev Date: Wed, 26 Jan 2022 13:51:44 +0000 (+0300) Subject: REDO_STOP_IF_MODIFIED X-Git-Tag: v1.22.0~1 X-Git-Url: http://www.git.cypherpunks.ru/?p=goredo.git;a=commitdiff_plain;h=61724b2573b9a0a27fa381c3809ad86ba55acfa7 REDO_STOP_IF_MODIFIED --- diff --git a/doc/cmds.texi b/doc/cmds.texi index b4e7bf5..de8d374 100644 --- a/doc/cmds.texi +++ b/doc/cmds.texi @@ -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 diff --git a/doc/features.texi b/doc/features.texi index 13530ae..4d0364b 100644 --- a/doc/features.texi +++ b/doc/features.texi @@ -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}, diff --git a/doc/news.texi b/doc/news.texi index 69ba830..1dbdb85 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -13,6 +13,10 @@ 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 63de931..f75edd4 100644 --- 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 6366f4a..ba84152 100644 --- 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 }()