Skip to content

Commit

Permalink
cli: normalize repository path specified by -R
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yuja committed Dec 18, 2024
1 parent 20414da commit 2b9ffdf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cli/src/cli_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down

0 comments on commit 2b9ffdf

Please sign in to comment.