Skip to content

Commit b8a0250

Browse files
committed
add SourceTree::Plain variant
1 parent 2d9c08e commit b8a0250

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/espidf.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,14 @@ pub struct EspIdf {
138138
#[derive(Debug, Clone)]
139139
pub enum SourceTree {
140140
Git(git::Repository),
141+
Plain(PathBuf),
141142
}
142143

143144
impl SourceTree {
144145
pub fn path(&self) -> &Path {
145146
match self {
146147
SourceTree::Git(repo) => repo.worktree(),
148+
SourceTree::Plain(path) => path,
147149
}
148150
}
149151
}
@@ -155,9 +157,9 @@ impl EspIdf {
155157
let idf_path = env::var_os(IDF_PATH_VAR).ok_or_else(|| {
156158
FromEnvError::NoRepo(anyhow!("environment variable `{IDF_PATH_VAR}` not found"))
157159
})?;
158-
let tree = match git::Repository::open(idf_path) {
160+
let tree = match git::Repository::open(&idf_path) {
159161
Ok(repo) => SourceTree::Git(repo),
160-
Err(e) => { return Err(FromEnvError::NoRepo(e)); }
162+
Err(_) => SourceTree::Plain(PathBuf::from(idf_path)),
161163
};
162164

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

0 commit comments

Comments
 (0)