aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index 6fbab07..dd7793f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -327,10 +327,11 @@ fn run_command(command: Commands) -> Result<()> {
327fn find_git_root() -> Result<PathBuf> { 327fn find_git_root() -> Result<PathBuf> {
328 let mut current = std::env::current_dir()?; 328 let mut current = std::env::current_dir()?;
329 329
330 loop { 330 // Find the git root directory
331 let git_root = loop {
331 let git_path = current.join(".git"); 332 let git_path = current.join(".git");
332 if git_path.exists() { 333 if git_path.exists() {
333 return Ok(current); 334 break current;
334 } 335 }
335 336
336 match current.parent() { 337 match current.parent() {
@@ -339,7 +340,30 @@ fn find_git_root() -> Result<PathBuf> {
339 "No git repository found. Please specify --root-dir or run from within a git repository" 340 "No git repository found. Please specify --root-dir or run from within a git repository"
340 )), 341 )),
341 } 342 }
343 };
344
345 // Create .demon subdirectory within git root
346 let demon_dir = git_root.join(".demon");
347
348 // Handle the case where .demon already exists
349 if demon_dir.exists() {
350 if !demon_dir.is_dir() {
351 return Err(anyhow::anyhow!(
352 "Path {} exists but is not a directory. Please remove it or specify --root-dir",
353 demon_dir.display()
354 ));
355 }
356 // .demon exists and is a directory, we can use it
357 return Ok(demon_dir);
342 } 358 }
359
360 // Create .demon directory
361 std::fs::create_dir(&demon_dir)
362 .with_context(|| format!("Failed to create daemon directory {}", demon_dir.display()))?;
363
364 tracing::info!("Created daemon directory: {}", demon_dir.display());
365
366 Ok(demon_dir)
343} 367}
344 368
345fn resolve_root_dir(global: &Global) -> Result<PathBuf> { 369fn resolve_root_dir(global: &Global) -> Result<PathBuf> {