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
27
28
29
30
31
32
33
34
35
36
impl crate::Repository {
pub fn path(&self) -> &std::path::Path {
self.git_dir()
}
pub fn work_dir(&self) -> Option<&std::path::Path> {
self.work_tree.as_deref()
}
pub fn install_dir(&self) -> std::io::Result<std::path::PathBuf> {
std::env::current_exe().and_then(|exe| {
exe.parent()
.map(ToOwned::to_owned)
.ok_or_else(|| std::io::Error::new(std::io::ErrorKind::Other, "no parent for current executable"))
})
}
pub fn kind(&self) -> crate::Kind {
match self.work_tree {
Some(_) => crate::Kind::WorkTree,
None => crate::Kind::Bare,
}
}
pub fn git_dir(&self) -> &std::path::Path {
self.refs.base()
}
}