doc/cmds.texi | 7 +++++++ doc/features.texi | 1 + doc/news.texi | 4 ++++ main.go | 1 + run.go | 7 ++++++- diff --git a/doc/cmds.texi b/doc/cmds.texi index 543e6191a9e643d20ae7224e0921c5bcf7c39de638cd9e1fb1db0654dff3b259..1c0b27369b00421769892dece37dc6c1529edcf0b1336839ed0421fbaaeef4c8 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 57d95b999102ffb8863d16549a40a1413476d1002cc1e71156e31fd0aad7f46f..1c96936ed15eb6a62688de2540ab365d7c7bcad20cae587324088c30566f477c 100644 --- a/doc/features.texi +++ b/doc/features.texi @@ -12,6 +12,7 @@ @item check that @file{$1} was not touched during .do execution @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 b1b08386d9dc04f690c8e02252fe7a26b2ddbf481952b73f584871ec17adf296..68a5cdab126a7e62cf240f65c59eb40450e94c82121837dffbd76a0ec1e10891 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -13,6 +13,10 @@ @file{.redo} directories and their dependency files, checks if 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 866eefbd0485af821ec75e9b9af15c5e4bf0736a5a7a2f3b5f54a0175f37468f..f10e630f778d37fae9f56f4ba05b804d66b906c2d2d2545bf8490602cab56f47 100644 --- a/main.go +++ b/main.go @@ -198,6 +198,7 @@ traced = *flagTrace } 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 eab2bd8363d1bd12d6a9a4b907f0d5c55315aa65722fe1c850148f3aa1acc5a6..bb0bab4664c53a6486ee82211658748576d5fdafd96b39dc5d410e1cb628618a 100644 --- a/run.go +++ b/run.go @@ -51,6 +51,7 @@ EnvTrace = "REDO_TRACE" EnvStderrKeep = "REDO_LOGS" EnvStderrSilent = "REDO_SILENT" EnvNoSync = "REDO_NO_SYNC" + EnvStopIfMod = "REDO_STOP_IF_MODIFIED" RedoDir = ".redo" LockSuffix = ".lock" @@ -65,6 +66,7 @@ NoSync = false StderrKeep = false StderrSilent = false StderrPrefix string + StopIfMod = false Jobs sync.WaitGroup flagTrace *bool @@ -273,8 +275,11 @@ lockRelease() return TgtError{tgtOrig, err} } if modified { + lockRelease() + if StopIfMod { + return fmt.Errorf("%s externally modified", tgtOrig) + } tracef(CWarn, "%s externally modified: not redoing", tgtOrig) - lockRelease() go func() { errs <- nil }()