feat: template caching for git-sourced templates#3
Merged
Conversation
- Cache cloned templates at ~/.cache/diecut/templates/ (XDG-compliant) - Deterministic cache keys with URL normalization (trailing .git, slashes) - get_or_clone() checks cache before cloning, with cross-filesystem fallback - list_cached() for enumerating cached templates with metadata - clear_cache() for selective or full cache removal - Cache metadata stored as .diecut-cache.toml per entry Closes diecut-l41
…lity) - Rename chrono_now() to unix_timestamp_secs(), update doc comments - Add normalize_url() helper for consistent URL comparison in clear_cache - Make get_cache_dir() configurable via DIECUT_CACHE_DIR env var, return Result - Reject file:// URLs in clone_template, warn on http:// - Move create_dir_all before clone operation in get_or_clone - Add UnsafeUrl error variant for URL scheme validation - Add tests for env var, URL normalization, and file:// rejection
Change get_or_clone to keep TempDir alive during cache placement. On error, TempDir drops and cleans up automatically. Only call tmp_dir.keep() after successful rename/copy into the cache directory. This prevents orphaned temp directories when metadata write, mkdir, or rename operations fail.
Add blocking-http-transport-reqwest-rust-tls feature to gix dependency. Without this, only file://, git://, and ssh:// transports were available, causing HTTPS clones (gh: abbreviations, https:// URLs) to fail silently.
raiderrobert
added a commit
that referenced
this pull request
Feb 12, 2026
feat: template caching for git-sourced templates
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.
Summary
~/.cache/diecut/templates/(XDG-compliant viadirscrate).git, slashes)get_or_clone()checks cache before cloning, with cross-filesystem rename fallbacklist_cached()for enumerating cached templates with metadataclear_cache()for selective or full cache removalStacks on #2 (git clone via gix).
Test plan
cargo clippywith-Dwarningspassescargo testpasses (cache key tests, XDG path test)diecut new gh:user/repohits cache instead of re-cloning