build: make build_source_package(None) default to the current directory
None mapped to Path::new("."), whose parent is the empty string:
the output-directory derivation then always failed with 'cannot
determine output directory', making the documented Option default a
guaranteed-failure trap. Resolve None to the process's absolute
current working directory instead.
This commit is contained in:
+11
-3
@@ -72,11 +72,19 @@ pub fn build_source_package(
|
||||
cwd: Option<&Path>,
|
||||
ui: Option<Arc<DebUi>>,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let cwd = cwd.unwrap_or_else(|| Path::new("."));
|
||||
let output = match run_source_build(cwd, &SourceBuildOptions::default(), ui.clone()) {
|
||||
// Default to the process's current working directory, resolved to an
|
||||
// absolute path: the output directory is derived from `cwd.parent()`
|
||||
// downstream, which only yields a real directory for an absolute `cwd`
|
||||
// (the parent of "." is the empty path).
|
||||
let cwd = match cwd {
|
||||
Some(p) => p.to_path_buf(),
|
||||
None => std::env::current_dir()
|
||||
.map_err(|e| format!("cannot determine the current working directory: {e}"))?,
|
||||
};
|
||||
let output = match run_source_build(&cwd, &SourceBuildOptions::default(), ui.clone()) {
|
||||
Ok(output) => output,
|
||||
Err(e) if e.downcast_ref::<VendorDriftError>().is_some() => {
|
||||
return retry_after_revendor(cwd, ui, e);
|
||||
return retry_after_revendor(&cwd, ui, e);
|
||||
}
|
||||
Err(e) => {
|
||||
if let Some(u) = &ui {
|
||||
|
||||
Reference in New Issue
Block a user