1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use super::*;
impl VMFileSystem {
#[cfg(feature = "native")]
pub fn find_git_root(base: &Path) -> Result<PathBuf> {
let mut path: PathBuf = base.into();
let git_root = Path::new(".git");
loop {
path.push(git_root);
if path.is_file() {
break Ok(path);
}
if !(path.pop() && path.pop()) {
break Err(NoteError::runtime_error("git root not found"));
}
}
}
#[cfg(feature = "native")]
pub fn find_git_repo(base: &Path) -> Result<Repository> {
let root = Self::find_git_root(base)?;
Ok(Repository::open(root)?)
}
}