Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Unify placeholder filter patterns (#262)

Maximilian Roos6b6578728515
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index e055c5db2..5331a5d22 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -1835,33 +1835,21 @@ pub fn setup_snapshot_settings(repo: &TestRepo) -> insta::Settings {
);
// Final cleanup: strip any remaining quotes around placeholders.
- // This handles cases where ANSI codes are inserted between the quote and path content,
- // causing the quoted path filter to not match. The path filter replaces the path with
- // the placeholder, but the surrounding quotes from shell_escape remain.
- // The pattern matches quotes with optional ANSI escape sequences inside.
- settings.add_filter(r"'(?:\x1b\[[0-9;]*m)*_REPO_(?:\x1b\[[0-9;]*m)*'", "_REPO_");
+ // shell_escape may quote paths, and ANSI codes may appear between quotes and content.
+ // This unified pattern matches all placeholder types: _REPO_, _REPO_.suffix, _WORKTREE_X_
settings.add_filter(
- r"'(?:\x1b\[[0-9;]*m)*_REPO_(\.[a-zA-Z0-9_-]+)(?:\x1b\[[0-9;]*m)*'",
- "_REPO_$1",
- );
- // Match quoted worktree placeholders (with optional ANSI codes) and strip the quotes
- settings.add_filter(
- r"'(?:\x1b\[[0-9;]*m)*(_WORKTREE_[A-Z0-9_]+_)(?:\x1b\[[0-9;]*m)*'",
+ r"'(?:\x1b\[[0-9;]*m)*(_(?:REPO|WORKTREE_[A-Z0-9_]+)_(?:\.[a-zA-Z0-9_-]+)?)(?:\x1b\[[0-9;]*m)*'",
"$1",
);
- // Normalize syntax highlighting around _REPO_ placeholders.
+ // Normalize syntax highlighting around placeholders.
// Bash syntax highlighters may split tokens differently on different platforms.
// Linux CI produces: [2m [0m[2m[32m_REPO_[0m[2m [0m (space, green path, space as separate spans)
// macOS local produces: [2m _REPO_ [0m (all in one span)
- // The [32m is green color applied to _REPO_ which the local highlighter doesn't add.
+ // The [32m is green color applied to placeholders which the local highlighter doesn't add.
// Normalize CI format to local format by matching the split pattern and merging.
settings.add_filter(
- r"\x1b\[2m \x1b\[0m\x1b\[2m(?:\x1b\[32m)?(_REPO_(?:\.[a-zA-Z0-9_-]+)?)(?:\x1b\[0m)?\x1b\[2m \x1b\[0m",
- "\x1b[2m $1 \x1b[0m",
- );
- settings.add_filter(
- r"\x1b\[2m \x1b\[0m\x1b\[2m(?:\x1b\[32m)?(_WORKTREE_[A-Z0-9_]+_)(?:\x1b\[0m)?\x1b\[2m \x1b\[0m",
+ r"\x1b\[2m \x1b\[0m\x1b\[2m(?:\x1b\[32m)?(_(?:REPO|WORKTREE_[A-Z0-9_]+)_(?:\.[a-zA-Z0-9_-]+)?)(?:\x1b\[0m)?\x1b\[2m \x1b\[0m",
"\x1b[2m $1 \x1b[0m",
);