From: Sergey Matveev Date: Fri, 19 Nov 2021 11:08:07 +0000 (+0300) Subject: Warn simultaneous ifcreate/ifchange usage X-Git-Tag: v1.20.0^0 X-Git-Url: http://www.git.cypherpunks.ru/?p=goredo.git;a=commitdiff_plain;h=dec78abffe14ae2e7c3383c215803c3792788d3e Warn simultaneous ifcreate/ifchange usage --- diff --git a/doc/news.texi b/doc/news.texi index 4f5ab5b..d74791e 100644 --- a/doc/news.texi +++ b/doc/news.texi @@ -1,6 +1,14 @@ @node News @unnumbered News +@anchor{Release 1_20_0} +@section Release 1.20.0 +@itemize +@item + Print warning message if both ifcreate and ifchange records were + discovered after the target is done. +@end itemize + @anchor{Release 1_19_0} @section Release 1.19.0 @itemize diff --git a/run.go b/run.go index a640148..0b77d49 100644 --- a/run.go +++ b/run.go @@ -731,6 +731,26 @@ func runScript(tgtOrig string, errs chan error, traced bool) error { goto Finish } } + + // Post-commit .rec sanitizing + fdDep.Close() + if fdDepR, err := os.Open(fdDepPath); err == nil { + depInfo, err := depRead(fdDepR) + fdDepR.Close() + if err != nil { + goto Finish + } + ifchangeSeen := make(map[string]struct{}, len(depInfo.ifchanges)) + for _, dep := range depInfo.ifchanges { + ifchangeSeen[dep["Target"]] = struct{}{} + } + for _, dep := range depInfo.ifcreates { + if _, exists := ifchangeSeen[dep]; exists { + tracef(CWarn, "simultaneous ifcreate and ifchange records: %s", tgt) + } + } + } + Finish: runErr.Err = err errs <- runErr diff --git a/t/goredo-both-ifcreate-ifchange.t b/t/goredo-both-ifcreate-ifchange.t new file mode 100755 index 0000000..e269fb4 --- /dev/null +++ b/t/goredo-both-ifcreate-ifchange.t @@ -0,0 +1,15 @@ +#!/bin/sh + +testname=`basename "$0"` +test_description="Check that warning exists when using both ifcreate/ifchange" +. $SHARNESS_TEST_SRCDIR/sharness.sh +export REDO_TOP_DIR="`pwd`" REDO_NO_PROGRESS=1 + +touch src +echo redo-ifchange src > tgt.do +echo redo-ifcreate src >> tgt.do +redo tgt 2>2 + +test_expect_success "warn exists" 'grep -q "simultaneous ifcreate and ifchange" 2' + +test_done diff --git a/usage.go b/usage.go index 7de522f..428c9bc 100644 --- a/usage.go +++ b/usage.go @@ -24,7 +24,7 @@ import ( ) const ( - Version = "1.19.0" + Version = "1.20.0" Warranty = `Copyright (C) 2020-2021 Sergey Matveev This program is free software: you can redistribute it and/or modify