feat: matcha new --template-url via shallow git clone

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-07-11 13:06:19 -05:00
1 parent de000cb27d
commit 2972326103
2 files changed
+51 -5

No files matched your search

+15 -3
View File
@@ -1,4 +1,5 @@
use assert_cmd::Command;
use std::process::Command as Proc;
use tempfile::tempdir;
#[test]
@@ -22,10 +23,21 @@ fn new_refuses_existing_dir() {
}
#[test]
fn new_with_template_url_stub_leaves_no_dir() {
fn new_clones_local_template() {
let d = tempdir().unwrap();
// build a bare-ish source repo to clone
let src = d.path().join("src-tmpl");
std::fs::create_dir_all(src.join("public")).unwrap();
std::fs::write(src.join("public/marker.txt"), "hi").unwrap();
Proc::new("git").args(["init", "-q"]).current_dir(&src).status().unwrap();
Proc::new("git").args(["add", "."]).current_dir(&src).status().unwrap();
Proc::new("git").args(["-c","user.email=t@t","-c","user.name=t",
"commit","-qm","init"]).current_dir(&src).status().unwrap();
let url = format!("file://{}", src.display());
Command::cargo_bin("matcha").unwrap()
.current_dir(d.path())
.args(["new", "demo", "--template-url", "gh:x/y"]).assert().failure();
assert!(!d.path().join("demo").exists());
.args(["new", "cloned", "--template-url", &url]).assert().success();
assert!(d.path().join("cloned/public/marker.txt").exists());
assert!(!d.path().join("cloned/.git").exists()); // .git stripped
}