]> Cypherpunks.ru repositories - goredo.git/commitdiff
Fix proper ifcreate relative paths
authorSergey Matveev <stargrave@stargrave.org>
Wed, 15 Sep 2021 20:13:13 +0000 (23:13 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 15 Sep 2021 20:13:13 +0000 (23:13 +0300)
doc/news.texi
main.go
t/goredo-rel-ifcreate.t [new file with mode: 0755]
usage.go

index 650c12c0968d5e814068d91670f61de14178cfe1..e4016ca2e4db8ff28b531ed72b58810571abca76 100644 (file)
@@ -1,6 +1,13 @@
 @node News
 @unnumbered News
 
+@anchor{Release 1_14_0}
+@section Release 1.14.0
+@itemize
+@item
+    Fixed @command{redo-ifcreate}'s targets proper relative paths to the target.
+@end itemize
+
 @anchor{Release 1_13_0}
 @section Release 1.13.0
 @itemize
diff --git a/main.go b/main.go
index 4338d0031cf606c22b87ec9616519c8fc6120aba..67c428c14a6b6661bdc9bf94ae4dac0a0cf1062b 100644 (file)
--- a/main.go
+++ b/main.go
@@ -308,7 +308,14 @@ CmdSwitch:
                        log.Fatalln("no", EnvDepFd)
                }
                for _, tgt := range tgts {
-                       err = ifcreate(fdDep, tgt)
+                       tgtRel, err := filepath.Rel(
+                               filepath.Join(Cwd, DirPrefix),
+                               filepath.Join(Cwd, tgt),
+                       )
+                       if err != nil {
+                               break
+                       }
+                       err = ifcreate(fdDep, tgtRel)
                        if err != nil {
                                break
                        }
diff --git a/t/goredo-rel-ifcreate.t b/t/goredo-rel-ifcreate.t
new file mode 100755 (executable)
index 0000000..bf5bcab
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+testname=`basename "$0"`
+test_description="Proper relative to DirPrefix ifcreate paths"
+. $SHARNESS_TEST_SRCDIR/sharness.sh
+export REDO_TOP_DIR="`pwd`" REDO_NO_PROGRESS=1
+
+mkdir -p a/b/c a/c
+echo whatever > a/b/c/dep
+cat > a/b/default.do <<EOF
+echo called \$1
+redo-ifcreate ../c/dep
+redo-ifchange c/dep
+EOF
+export REDO_NO_PROGRESS=1
+redo-ifchange a/b/c/file
+stat1=`stat a/b/c/file`
+redo-ifchange a/b/c/file
+stat2=`stat a/b/c/file`
+
+test_expect_success "file stays same" '[ "$stat1" = "$stat2" ]'
+
+touch a/c/dep
+redo-ifchange a/b/c/file
+stat3=`stat a/b/c/file`
+
+test_expect_success "ifcreate target works" '[ "$stat1" != "$stat3" ]'
+
+test_done
index c002eeb2ad1589663c40a4611a53e309e0fa80b5..4e49c2b3d360192c5d7c43da3656d5ba399ba066 100644 (file)
--- a/usage.go
+++ b/usage.go
@@ -24,7 +24,7 @@ import (
 )
 
 const (
-       Version  = "1.13.0"
+       Version  = "1.14.0"
        Warranty = `Copyright (C) 2020-2021 Sergey Matveev
 
 This program is free software: you can redistribute it and/or modify