Skip to content

feat: git clone via gix for remote template sources#2

Merged
raiderrobert merged 6 commits into
mainfrom
feat/m2-git-clone
Feb 12, 2026
Merged

feat: git clone via gix for remote template sources#2
raiderrobert merged 6 commits into
mainfrom
feat/m2-git-clone

Conversation

@raiderrobert

Copy link
Copy Markdown
Owner

Summary

  • Add gix dependency for pure-Rust git operations (no C deps)
  • Implement clone_template() with branch/tag/commit checkout via --ref
  • Wire Git source into generate() flow (replaces GitNotImplemented stub)
  • Add GitClone and GitCheckout error variants

Test plan

  • cargo clippy with -Dwarnings passes
  • cargo test passes
  • CI pipeline passes
  • Manual test: diecut new gh:user/repo clones and generates

- Add gix dependency for pure-Rust git operations (no C deps)
- Implement clone_template() with branch/tag/commit checkout via --ref
- Wire Git source into generate() flow (replaces GitNotImplemented stub)
- Add GitClone and GitCheckout error variants
- Clone to temp directory; caller owns cleanup

Closes diecut-fgz
- 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.
feat: template caching for git-sourced templates
@raiderrobert raiderrobert merged commit 35f4a1f into main Feb 12, 2026
3 of 4 checks passed
raiderrobert added a commit that referenced this pull request Feb 12, 2026
feat: git clone via gix for remote template sources
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant