fix: empty repo path

e.g. when resolving the string "helix" and interpreting it as a URL because no matching local repo has been found
This commit is contained in:
Tim Schubert 2025-08-24 14:55:52 +02:00
parent 9161f5799d
commit f7259f0441
No known key found for this signature in database

View file

@ -1,4 +1,4 @@
use anyhow::{Context, Result};
use anyhow::{Context, Result, anyhow};
use std::{
ffi::{OsStr, OsString},
fs::create_dir_all,
@ -40,6 +40,9 @@ impl SrcRoot {
}
fn ensure_repo_checkout(&self, url: &Url) -> Result<PathBuf> {
if url.path().is_empty() {
return Err(anyhow!("Empty repo path"));
}
let repo_path = self.as_repo_path(url);
if !repo_path.is_dir() {
create_dir_all(&repo_path)?;