Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions xtasks/crates/config/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ fn ask_confirmation(prompt: &str) -> bool {
}

fn run_load_preset(preset_name: &str, no_confirm: bool, current_dir: &Path) -> Result<(), Error> {
// Load the preset file from the `presets/` directory.
let preset_path = PathBuf::from("presets").join(format!("{preset_name}.toml"));
// Load the file, or get it from the `presets/` directory
let pb = PathBuf::from(preset_name);
let preset_path = if pb.is_file() {
pb
} else {
PathBuf::from("presets").join(format!("{preset_name}.toml"))
Comment on lines +78 to +83
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Load.preset CLI help text still says the argument "must correspond to a file in the presets/ directory without the .toml extension", but this function now accepts direct file paths as well. Update the clap docstring (and any related docs) so users discover the new behavior and don't get misled about what values are valid.

Copilot uses AI. Check for mistakes.
};
Comment on lines +79 to +84
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pb.is_file() (and the fallback PathBuf::from("presets")...) resolve paths relative to the process working directory, not the current_dir/--root passed into this function. Since just config invokes the xtask with --root {{justfile_directory()}}, running just from a different directory can cause existing preset paths to be missed and the wrong fallback path to be used. Consider resolving relative preset_names (and the presets/ directory) against current_dir to make --root consistently control where presets are found.

Suggested change
let pb = PathBuf::from(preset_name);
let preset_path = if pb.is_file() {
pb
} else {
PathBuf::from("presets").join(format!("{preset_name}.toml"))
};
// Resolve the preset path relative to `current_dir` (the `--root`), unless `preset_name` is absolute.
let candidate = if Path::new(preset_name).is_absolute() {
PathBuf::from(preset_name)
} else {
current_dir.join(preset_name)
};
let preset_path = if candidate.is_file() {
candidate
} else {
current_dir
.join("presets")
.join(format!("{preset_name}.toml"))
};

Copilot uses AI. Check for mistakes.

let preset = config::load_toml(&preset_path)?;

let config_path = current_dir.join(".cargo/config.toml");
Expand Down
Loading