Add git configuration and update gitignore for project template

- Introduced a new gitconfig.txt file with core settings for Git.
- Updated gitignore.txt to include entries for IDEs, environment files, and atlas executable.
- Modified init.rs to handle the new gitconfig file during project initialization.
This commit is contained in:
Joe 2026-02-11 16:09:28 -06:00
parent 77b9c0e520
commit 2cc1726975
3 changed files with 44 additions and 40 deletions

View file

@ -0,0 +1,5 @@
[core]
autocrlf = false
excludesFile = ~/.gitignore
eol = lf
safecrlf = false

View file

@ -8,3 +8,12 @@
# Sourcemap # Sourcemap
/sourcemap.json /sourcemap.json
# IDEs
/.idea
# .env
/.env
# atlas
/atlas.exe

View file

@ -18,6 +18,7 @@ use memofs::{InMemoryFs, Vfs, VfsSnapshot};
use super::resolve_path; use super::resolve_path;
const GIT_IGNORE_PLACEHOLDER: &str = "gitignore.txt"; const GIT_IGNORE_PLACEHOLDER: &str = "gitignore.txt";
const GIT_CONFIG_PLACEHOLDER: &str = "gitconfig.txt";
static TEMPLATE_BINCODE: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/templates.bincode")); static TEMPLATE_BINCODE: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/templates.bincode"));
@ -106,6 +107,12 @@ impl InitCommand {
} else { } else {
path.set_file_name(".gitignore"); path.set_file_name(".gitignore");
} }
} else if file_stem == GIT_CONFIG_PLACEHOLDER {
if self.skip_git {
continue;
} else {
path.set_file_name(".gitconfig");
}
} }
} }
write_if_not_exists( write_if_not_exists(
@ -132,50 +139,33 @@ impl InitCommand {
}; };
if !self.skip_rules { if !self.skip_rules {
if did_git_init { log::debug!("Cloning cursor rules...");
log::debug!("Adding cursor rules as submodule...");
let result = Command::new("git") let cursor_dir = base_path.join(".cursor");
.args([ let result = Command::new("git")
"submodule", .args([
"add", "clone",
"https://github.com/jrmelsha/cursor-rules.git", "--depth",
".cursor", "1",
]) "https://github.com/jrmelsha/cursor-rules.git",
.current_dir(&base_path) ".cursor",
.stdout(Stdio::null()) ])
.stderr(Stdio::null()) .current_dir(&base_path)
.status(); .stdout(Stdio::null())
.stderr(Stdio::null())
.status();
match result { match result {
Ok(status) if status.success() => { Ok(status) if status.success() => {
println!("Added cursor rules as submodule."); // Remove .git so it's just files, not a submodule
} let git_dir = cursor_dir.join(".git");
_ => { if git_dir.exists() {
log::debug!("Failed to add cursor rules submodule, skipping."); let _ = fs::remove_dir_all(&git_dir);
} }
println!("Cloned cursor rules successfully.");
} }
} else { _ => {
log::debug!("Cloning cursor rules (no git repo)..."); log::debug!("Failed to clone cursor rules, skipping.");
let result = Command::new("git")
.args([
"clone",
"https://github.com/jrmelsha/cursor-rules.git",
".cursor",
])
.current_dir(&base_path)
.stdout(Stdio::null())
.stderr(Stdio::null())
.status();
match result {
Ok(status) if status.success() => {
println!("Cloned cursor rules successfully.");
}
_ => {
log::debug!("Failed to clone cursor rules, skipping.");
}
} }
} }
} }