cli: normalize repository path specified by -R

This will simplify path comparison in config resolver. <cwd>/.. shouldn't match
path prefix <cwd>. Maybe we should do path canonicalization globally (or never
do canonicalization), but I'm not sure where that should be made.
This commit is contained in:
Yuya Nishihara 2024-12-17 16:53:38 +09:00
parent dc9caa5b0a
commit eecb8d0746

View file

@ -3677,10 +3677,13 @@ impl CliRunner {
}
let maybe_workspace_loader = if let Some(path) = &args.global_args.repository {
// TODO: maybe path should be canonicalized by WorkspaceLoader?
let abs_path = cwd.join(path);
let abs_path = abs_path.canonicalize().unwrap_or(abs_path);
// Invalid -R path is an error. No need to proceed.
let loader = self
.workspace_loader_factory
.create(&cwd.join(path))
.create(&abs_path)
.map_err(|err| map_workspace_load_error(err, Some(path)))?;
config_env.reset_repo_path(loader.repo_path());
config_env.reload_repo_config(&mut config)?;