]> Cypherpunks.ru repositories - goredo.git/commitdiff
Explicitly check if $1 unexpectedly appears
authorSergey Matveev <stargrave@stargrave.org>
Thu, 30 Sep 2021 10:17:49 +0000 (13:17 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 30 Sep 2021 10:40:36 +0000 (13:40 +0300)
doc/news.texi
run.go
t/goredo-$1-touch.t [new file with mode: 0755]
usage.go

index e4016ca2e4db8ff28b531ed72b58810571abca76..ab7b9a14074b160fa555a0384c06ba6298e46fc8 100644 (file)
@@ -1,6 +1,14 @@
 @node News
 @unnumbered News
 
+@anchor{Release 1_15_0}
+@section Release 1.15.0
+@itemize
+@item
+    Explicitly check if @code{$1} target is touched and then fail.
+    Previously we check if @code{$1} was only altered.
+@end itemize
+
 @anchor{Release 1_14_0}
 @section Release 1.14.0
 @itemize
diff --git a/run.go b/run.go
index ca8eebbcd9ca542dd7c9f31e77dfaca18eb4b7de..f356d81488c2d895ee22eee1874b549219f23169 100644 (file)
--- a/run.go
+++ b/run.go
@@ -587,6 +587,29 @@ func runScript(tgtOrig string, errs chan error, traced bool) error {
                }
 
                // Was $1 touched?
+               if fd, err := os.Open(path.Join(cwdOrig, tgt)); err == nil {
+                       errTouched := errors.New("$1 was explicitly touched")
+                       if inodePrev == nil {
+                               fd.Close()
+                               runErr.Err = errTouched
+                               errs <- runErr
+                               return
+                       } else {
+                               inode, err := inodeFromFile(fd)
+                               fd.Close()
+                               if err != nil {
+                                       runErr.Err = err
+                                       errs <- runErr
+                                       return
+                               }
+                               if !inode.Equals(inodePrev) {
+                                       runErr.Err = errTouched
+                                       errs <- runErr
+                                       return
+                               }
+                       }
+               }
+
                if inodePrev != nil {
                        if fd, err := os.Open(path.Join(cwdOrig, tgt)); err == nil {
                                inode, err := inodeFromFile(fd)
diff --git a/t/goredo-$1-touch.t b/t/goredo-$1-touch.t
new file mode 100755 (executable)
index 0000000..0d73b02
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+testname=`basename "$0"`
+test_description="Check failing if unexistent \$1 is touched"
+. $SHARNESS_TEST_SRCDIR/sharness.sh
+export REDO_TOP_DIR="`pwd`" REDO_NO_PROGRESS=1
+
+echo touch \$1 > foo.do
+test_expect_success "it fails" 'redo foo ; [ $? = 1 ]'
+
+test_done
index 4e49c2b3d360192c5d7c43da3656d5ba399ba066..cb4c75665241f60697d3dfd5baec9264d86b8c30 100644 (file)
--- a/usage.go
+++ b/usage.go
@@ -24,7 +24,7 @@ import (
 )
 
 const (
-       Version  = "1.14.0"
+       Version  = "1.15.0"
        Warranty = `Copyright (C) 2020-2021 Sergey Matveev
 
 This program is free software: you can redistribute it and/or modify