Repository navigation
feat: dynamic paths — date, hostname, user and env placeholders - #5
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds “dynamic paths” support so saved rsync profiles can include date/host/user placeholders and environment variables that are expanded internally on each run (no shell). This also improves reliability for nested local sync destinations by creating missing parent directories before invoking rsync.
Changes:
- Implement placeholder (
{now},{now:...},{utcnow},{hostname},{user}) and environment variable ($VAR,${VAR}) expansion viacrate::paths::expand_path. - Ensure nested local sync destinations work by creating destination parent directories in
prepare_dest(not just snapshots). - Add unit/integration tests plus README documentation for dynamic paths.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/ui/fields.rs | Uses expand_path for status checks and updates dest hinting; adds tests for placeholder paths and nested parents. |
| src/rsync.rs | Switches local expansion to expand_path and extends prepare_dest to create parents for sync; adds tests including a live rsync nested-dest case. |
| src/paths.rs | Introduces placeholder + env expansion pipeline (expand_path) and associated tests. |
| README.md | Documents the new dynamic path placeholder/env syntax. |
Comments suppressed due to low confidence (1)
src/paths.rs:171
path_hitscurrently treats any non-absolute buffer containing ':' as remote. With formatted placeholders ({now:...}), the literal ':' in the placeholder syntax can incorrectly disable local path completion for inputs like~/{now:%Y-%m-%d}/. Using the expanded path for the remote-path heuristic avoids this false positive.
pub fn path_hits(buffer: &str) -> Vec<String> {
if buffer.contains('@') || (buffer.contains(':') && !buffer.starts_with('/')) {
return Vec::new();
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
104
to
107
| pub(crate) fn field_status(buffer: &str, focused: bool, is_dest: bool) -> (Color, Option<String>) { | ||
| let b = buffer.trim(); | ||
| if b.is_empty() || is_remote_buf(b) { | ||
| return (accent(), None); |
Comment on lines
+180
to
+182
| Unknown placeholders, unset variables and a bare `%` are left exactly as typed, | ||
| and the dry-run preview always shows the resolved path before anything runs. | ||
| Write `{{` for a literal brace and `$$` for a literal `$`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Source and destination paths can now contain placeholders, resolved on every run:
{now}/{now:FORMAT}(any strftime format),{utcnow},{hostname},{user}, plus$VAR/${VAR}environment variables. Expanded internally; no shell is involved, so profile fields never execute anything.{{and$$are literal escapes.%in a path is untouched — the delimited{…}syntax means an existing folder like100%donekeeps its name.{nowx}is visible in the preview instead of silently resolving to the wrong destination.{hostname}/{now:%Y-%m-%d}previously failed at run time withmkdir … No such file or directoryeven though the dry-run preview reported success.prepare_destnow creates missing parents for local sync destinations, as it already did for snapshots.Related to #1. Remote destinations with 2+ new levels are still unsupported (parents can't be created on the far side).