git_shell/git/
work_tree.rs1use std::{
6 io::{Error, ErrorKind},
7 path::{Path, PathBuf},
8};
9
10use crate::Result;
11
12pub (crate) const CMD_LIST: &str = "list";
14
15pub (crate) const OPTION_PORCELAIN: &str = "--porcelain";
17
18pub (crate) const OPTION_Z: &str = "-z";
20
21#[derive(Debug, Eq, PartialEq, Hash)]
25pub struct WorkTree {
26
27 path: PathBuf,
28
29}
30
31impl WorkTree {
32
33 pub (crate) fn make<P>(path: P) -> Result<Self> where P: AsRef<Path> {
37 let path = path.as_ref().to_path_buf().canonicalize()?;
38 if path.is_dir() {
39 Ok(Self {
40 path,
41 })
42 } else {
43 Err(Error::new(ErrorKind::InvalidInput, __!("Not a directory: {:?}", path)))
44 }
45 }
46
47 pub fn path(&self) -> &Path {
49 &self.path
50 }
51
52}