diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:45:23 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:45:23 +0200 |
| commit | 97c8164bc81e0a438dab92d7244485005dac4ff2 (patch) | |
| tree | 08d657f8b92a6539259b6aa8f08b0e9ef8cc6710 /internal/engine | |
| parent | 166565025832c8a8faf7397766aeaa878980dd2d (diff) | |
| download | krino-97c8164bc81e0a438dab92d7244485005dac4ff2.tar.gz krino-97c8164bc81e0a438dab92d7244485005dac4ff2.zip | |
literal braces are text, not placeholders, for containment and walk exclusion
Diffstat (limited to 'internal/engine')
| -rw-r--r-- | internal/engine/match.go | 5 | ||||
| -rw-r--r-- | internal/engine/match_test.go | 2 |
2 files changed, 4 insertions, 3 deletions
diff --git a/internal/engine/match.go b/internal/engine/match.go index 0e8b3d5..9f5ff12 100644 --- a/internal/engine/match.go +++ b/internal/engine/match.go @@ -501,9 +501,8 @@ func (e *Engine) excludeDirs(d *Dir) []string { if a.Kind != config.Copy && a.Kind != config.Move { continue } - prefix := a.Arg - if idx := strings.IndexByte(prefix, '{'); idx >= 0 { - prefix = prefix[:idx] + prefix, templated := plan.StaticPrefix(a.Arg) + if templated { if idx2 := strings.LastIndexByte(prefix, '/'); idx2 >= 0 { prefix = prefix[:idx2] } else { diff --git a/internal/engine/match_test.go b/internal/engine/match_test.go index 477e06f..f2a01bc 100644 --- a/internal/engine/match_test.go +++ b/internal/engine/match_test.go @@ -267,6 +267,7 @@ func TestExcludeDirs(t *testing.T) { (rule "r7" (move "` + absDest + `")) (rule "r8" (copy "Backup")) (rule "r9" (rename "x-{name}")) +(rule "r10" (move "Lit/{{a}}/{mtime:%Y}")) ` main := writeConfig(t, h, `(include "dl")`, map[string]string{"dl": conf}) e, errs := Load(main) @@ -285,6 +286,7 @@ func TestExcludeDirs(t *testing.T) { absDest, // r7: absolute, already inside root filepath.Join(root, "Backup"), // r8: copy counts like move // r9 rename "x-{name}": rename is never a destination. + filepath.Join(root, "Lit", "{a}"), // r10: "{{a}}" is literal text } if !reflect.DeepEqual(got, want) { t.Fatalf("excludeDirs =\n%v\nwant\n%v", got, want) |
