Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 6 additions & 17 deletions crates/rig-cli/src/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,26 +191,15 @@ fn legacy_warnings(home: &Home) -> Vec<String> {
return Vec::new();
};
[
(
"plugins.toml",
"plugins",
"plugin list goes",
"`enable` and `disable` for rig's plugins, [[plugins.extra]] for other crates; \
`rig plugin list` shows what is on",
),
(
"defaults.json",
"model",
"model and effort go",
"`default` and `effort`",
),
("plugins.toml", "plugin list", "plugins"),
("defaults.json", "model and effort", "model"),
]
.into_iter()
.filter(|(old, table, ..)| home.root().join(old).exists() && !file.document.contains_key(table))
.map(|(old, table, what, keys)| {
.filter(|(old, _, table)| home.root().join(old).exists() && !file.document.contains_key(table))
.map(|(old, what, table)| {
format!(
"{} is from rig 0.46 or earlier and rig no longer reads it: its {what} in \
[{table}] of {} now ({keys}). rig leaves the file as it is.",
"rig no longer reads {}. Move its {what} to [{table}] in {} (see MIGRATING.md). \
The file was not changed.",
home.root().join(old).display(),
settings.display(),
)
Expand Down
22 changes: 17 additions & 5 deletions crates/rig-cli/src/run/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,9 +1036,9 @@ exit 0";

/// A home rig 0.46 left, with `plugins.toml` and `defaults.json` that
/// `settings.toml` has no `[plugins]` or `[model]` for, is warned of once
/// per run, a line per file naming where its settings go now, and its
/// files are left as they are. A home whose settings cover them, and a
/// fresh home, are not warned of.
/// per run, a line per file naming the table its settings move to and
/// MIGRATING.md, and its files are left as they are. A home whose settings
/// cover them, even with empty tables, and a fresh home, are not warned of.
#[cfg(unix)]
#[test]
fn a_0_46_home_is_warned_of_once_per_run_and_left_as_it_is() {
Expand All @@ -1064,8 +1064,11 @@ fn a_0_46_home_is_warned_of_once_per_run_and_left_as_it_is() {
assert!(
lines
.iter()
.any(|line| line.contains(file) && line.contains(table)),
"no warning names {file} and {table}: {lines:?}"
.any(|line| line.starts_with("rig no longer reads ")
&& line.contains(file)
&& line.contains(table)
&& line.contains("MIGRATING.md")),
"no warning names {file}, {table} and MIGRATING.md: {lines:?}"
);
}
let again = starts.as_ref().ok().and_then(|starts| starts.get(1));
Expand All @@ -1082,6 +1085,15 @@ fn a_0_46_home_is_warned_of_once_per_run_and_left_as_it_is() {
let starts = starts.map_err(|failure| failure.to_string());
assert_eq!(starts, Ok(vec![String::new(), String::new()]));

let empty = builds("legacy-empty", "", "");
let wrote = fs::write(empty.root().join("plugins.toml"), plugins)
.and_then(|()| fs::write(empty.root().join("defaults.json"), defaults))
.and_then(|()| fs::write(empty.settings(), "[plugins]\n\n[model]\n"));
let starts = wrote.map_err(Into::into).and_then(|()| warned(&empty));
fs::remove_dir_all(empty.root()).ok();
let starts = starts.map_err(|failure| failure.to_string());
assert_eq!(starts, Ok(vec![String::new(), String::new()]));

let fresh = builds("legacy-fresh", "", "");
let starts = warned(&fresh).map_err(|failure| failure.to_string());
fs::remove_dir_all(fresh.root()).ok();
Expand Down
Loading