aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/engine/engine_test.go2
-rw-r--r--internal/plan/placeholder.go3
2 files changed, 5 insertions, 0 deletions
diff --git a/internal/engine/engine_test.go b/internal/engine/engine_test.go
index 4af8f79..7de2f76 100644
--- a/internal/engine/engine_test.go
+++ b/internal/engine/engine_test.go
@@ -272,6 +272,8 @@ func TestLoadRefusesBadPlaceholders(t *testing.T) {
{`(rename "{0}-x")`, "numbered from 1"},
{`(copy "Out/{10}")`, "unknown placeholder {10}"},
{`(move "Out/{name")`, "unclosed placeholder"},
+ {`(move "Out/{mtime:}")`, "needs a format"},
+ {`(move "Out/{now:}")`, "needs a format"},
} {
h := sandbox(t)
os.MkdirAll(filepath.Join(h, "dl"), 0o755)
diff --git a/internal/plan/placeholder.go b/internal/plan/placeholder.go
index 5922b07..5675e01 100644
--- a/internal/plan/placeholder.go
+++ b/internal/plan/placeholder.go
@@ -143,6 +143,9 @@ func expandOne(body string, f Facts) (string, error) {
// they point at what the config author actually wrote (B3) instead of
// hardcoding "mtime" for a {now:...} format error.
func strftime(verb, format string, t time.Time) (string, error) {
+ if format == "" {
+ return "", fmt.Errorf("{%s:} needs a format, like {%s:%%Y}", verb, verb)
+ }
var b strings.Builder
for i := 0; i < len(format); i++ {
c := format[i]