mirror of
https://github.com/dexoron/dcr.git
synced 2026-10-21 10:38:31 +00:00
refactor(deps): replace git2 with system git and add vcs support
This commit is contained in:
@@ -99,6 +99,60 @@ fn new_creates_project_layout() {
|
||||
);
|
||||
}
|
||||
|
||||
fn is_git_in_path() -> bool {
|
||||
std::process::Command::new("git")
|
||||
.arg("--version")
|
||||
.output()
|
||||
.map(|o| o.status.success())
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn new_vcs_options_work() {
|
||||
// 1. Test --vcs none
|
||||
let dir = unique_sandbox_dir("new_vcs_none");
|
||||
let out = run_dcr(&["new", "hello_none", "--vcs", "none"], &dir);
|
||||
assert!(out.status.success(), "dcr new --vcs none should succeed");
|
||||
let project_dir = dir.join("hello_none");
|
||||
assert!(project_dir.is_dir());
|
||||
assert!(!project_dir.join(".git").exists());
|
||||
assert!(!project_dir.join(".gitignore").exists());
|
||||
|
||||
// 2. Test --vcs git
|
||||
if is_git_in_path() {
|
||||
let dir = unique_sandbox_dir("new_vcs_git");
|
||||
let out = run_dcr(&["new", "hello_git", "--vcs", "git"], &dir);
|
||||
assert!(out.status.success(), "dcr new --vcs git should succeed");
|
||||
let project_dir = dir.join("hello_git");
|
||||
assert!(project_dir.is_dir());
|
||||
assert!(project_dir.join(".git").is_dir());
|
||||
assert!(project_dir.join(".gitignore").is_file());
|
||||
let gitignore = std::fs::read_to_string(project_dir.join(".gitignore")).unwrap();
|
||||
assert!(gitignore.contains("/target"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn init_vcs_options_work() {
|
||||
// 1. Test --vcs none
|
||||
let dir = unique_sandbox_dir("init_vcs_none");
|
||||
let out = run_dcr(&["init", "--vcs", "none"], &dir);
|
||||
assert!(out.status.success(), "dcr init --vcs none should succeed");
|
||||
assert!(!dir.join(".git").exists());
|
||||
assert!(!dir.join(".gitignore").exists());
|
||||
|
||||
// 2. Test --vcs git
|
||||
if is_git_in_path() {
|
||||
let dir = unique_sandbox_dir("init_vcs_git");
|
||||
let out = run_dcr(&["init", "--vcs", "git"], &dir);
|
||||
assert!(out.status.success(), "dcr init --vcs git should succeed");
|
||||
assert!(dir.join(".git").is_dir());
|
||||
assert!(dir.join(".gitignore").is_file());
|
||||
let gitignore = std::fs::read_to_string(dir.join(".gitignore")).unwrap();
|
||||
assert!(gitignore.contains("/target"));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn init_and_clean_remove_target() {
|
||||
let dir = unique_sandbox_dir("init");
|
||||
|
||||
Reference in New Issue
Block a user