}
}
levels = append(levels, "..")
- dirAbs, err := filepath.Abs(updir)
+ dirAbs, err := filepath.Abs(path.Join(cwd, updir))
if err != nil {
panic(err)
}
@node News
@unnumbered News
+@anchor{Release 0.13.0}
+@section Release 0.13.0
+@itemize
+@item
+ @command{redo-whichdo} resembles @code{apenwarr/redo}'s one behaviour more.
+@end itemize
+
@anchor{Release 0.12.3}
@section Release 0.12.3
@itemize
"path"
"path/filepath"
"strconv"
- "strings"
"go.cypherpunks.ru/recfile"
)
}
os.Remove(fdTmp.Name())
cwd, tgt := cwdAndTgt(tgts[0])
- cwdRel := cwdMustRel(cwd)
doFile, upLevels, err := findDo(fdTmp, cwd, tgt)
if err != nil {
break
if doFile == "" {
ok = false
} else {
- fmt.Println(path.Join(cwdRel, strings.Repeat("..", upLevels), doFile))
+ p := make([]string, 0, upLevels+2)
+ p = append(p, cwd)
+ for i := 0; i < upLevels; i++ {
+ p = append(p, "..")
+ }
+ p = append(p, doFile)
+ rel, err := filepath.Rel(Cwd, path.Join(p...))
+ if err != nil {
+ panic(err)
+ }
+ fmt.Println(rel)
}
default:
log.Fatalln("unknown command", cmdName)
--- /dev/null
+redo exists nonexists defaults
--- /dev/null
+exec >&2
+
+a=$(cd fakesub2 && redo-whichdo d/snork)
+# if sh doesn't abort after the above, then it found a .do file as expected
+
+b=$(cat <<EOF
+d/snork.do
+d/default.do
+default.do
+EOF
+)
+
+if [ "$a" != "$b" ]; then
+ printf 'redo-whichdo mismatch.\n\ngot:\n%s\n\nexpected:\n%s\n' "$a" "$b"
+ exit 11
+fi
--- /dev/null
+exec >&2
+
+a=$(cd fakesub && redo-whichdo ../a/b/x.y.z)
+# if sh doesn't abort after the above, then it found a .do file as expected
+
+# Note: we expect redo-whichdo to return paths relative to $PWD at the time
+# it's run, which in this case is fakesub.
+# Likely bugs would be to return paths relative to the start dir, the .redo
+# dir, the current target dir, the requested target dir, etc.
+b=$(cat <<EOF
+../a/b/x.y.z.do
+../a/b/default.y.z.do
+../a/b/default.z.do
+../a/b/default.do
+../a/default.y.z.do
+../a/default.z.do
+../a/default.do
+../default.y.z.do
+EOF
+)
+
+if [ "$a" != "$b" ]; then
+ printf 'redo-whichdo mismatch.\n\ngot:\n%s\n\nexpected:\n%s\n' "$a" "$b"
+ exit 11
+fi
--- /dev/null
+exec >&2
+
+# Testing the search path for non-existent do files is a little tricky.
+# We can't be sure where our current directory is, so we don't know how
+# far up the stack redo will need to search.
+#
+# To dodge the problem, let's "cd /" first so that we're testing a target
+# relative to a known location (the root directory).
+
+if [ -e '/default.do' -o \
+ -e '/default.z.do' -o \
+ -e '/default.y.z.do' ]; then
+ echo "Weird: /default.*.do exists; can't run this test."
+ exit 99
+fi
+
+# redo-whichdo *should* fail here, so don't abort the script for that.
+set +e
+a=$(cd / && redo-whichdo __nonexist/a/x.y.z)
+rv=$?
+set -e
+
+if [ "$rv" -eq 0 ]; then
+ echo "redo-whichdo should return nonzero for a missing .do file."
+ exit 10
+fi
+
+b=$(cat <<EOF
+__nonexist/a/x.y.z.do
+__nonexist/a/default.y.z.do
+__nonexist/a/default.z.do
+__nonexist/a/default.do
+__nonexist/default.y.z.do
+__nonexist/default.z.do
+__nonexist/default.do
+default.y.z.do
+default.z.do
+default.do
+EOF
+)
+
+if [ "$a" != "$b" ]; then
+ printf 'redo-whichdo mismatch.\n\ngot:\n%s\n\nexpected:\n%s\n' "$a" "$b"
+ exit 11
+fi
Those tests are taken from https://github.com/apenwarr/redo.
-* Only basic ([01]*) tests taken, because other ones are too apenwarr
- implementation specific.
+* Only basic ([01]*, 260-whichdo) tests taken, because other ones are
+ too apenwarr implementation specific
* 140-shuffle and 141-keep-going removed, because apenwarr specific
* flush-cache removed, as it works directly with apenwarr's database
* redo/sh and redo/py targets replaced with /bin/sh and ${PYTHON}
--- /dev/null
+apenwarr/wrapper.rc
\ No newline at end of file
)
const (
- Version = "0.12.3"
+ Version = "0.13.0"
Warranty = `This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.