Skip to content

Commit

Permalink
add SourceTree::Plain variant
Browse files Browse the repository at this point in the history
  • Loading branch information
haileys committed Sep 15, 2023
1 parent 2d9c08e commit b8a0250
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/espidf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,14 @@ pub struct EspIdf {
#[derive(Debug, Clone)]
pub enum SourceTree {
Git(git::Repository),
Plain(PathBuf),
}

impl SourceTree {
pub fn path(&self) -> &Path {
match self {
SourceTree::Git(repo) => repo.worktree(),
SourceTree::Plain(path) => path,
}
}
}
Expand All @@ -155,9 +157,9 @@ impl EspIdf {
let idf_path = env::var_os(IDF_PATH_VAR).ok_or_else(|| {
FromEnvError::NoRepo(anyhow!("environment variable `{IDF_PATH_VAR}` not found"))
})?;
let tree = match git::Repository::open(idf_path) {
let tree = match git::Repository::open(&idf_path) {
Ok(repo) => SourceTree::Git(repo),
Err(e) => { return Err(FromEnvError::NoRepo(e)); }
Err(_) => SourceTree::Plain(PathBuf::from(idf_path)),
};

let path_var = env::var_os("PATH").unwrap_or_default();
Expand Down

0 comments on commit b8a0250

Please sign in to comment.