1pub mod session;
2pub mod tracing;
3
4use std::path::Path;
5
6pub fn is_git_repo(path: &Path) -> bool {
8 let git_dir = path.join(".git");
9 git_dir.exists() && git_dir.is_dir()
10}
11
12pub fn get_platform() -> String {
14 #[cfg(target_os = "linux")]
15 return "linux".to_string();
16
17 #[cfg(target_os = "macos")]
18 return "macos".to_string();
19
20 #[cfg(target_os = "windows")]
21 return "windows".to_string();
22
23 #[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
24 return "unknown".to_string();
25}
26
27pub fn escape_regex(s: &str) -> String {
29 let special_chars = r"[\^$.|?*+(){}";
30 let mut result = String::with_capacity(s.len() * 2);
31
32 for c in s.chars() {
33 if special_chars.contains(c) {
34 result.push('\\');
35 }
36 result.push(c);
37 }
38
39 result
40}