Fix alacritty migrate with nonexistent imports

Fixes #7473.
This commit is contained in:
Christian Duerr 2023-12-28 18:57:30 +01:00 committed by GitHub
parent 234fea701c
commit 81df32af60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -7,6 +7,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## 0.14.0-dev
### Fixed
- `alacritty migrate` failing with nonexistent imports
## 0.13.0
### Packaging

View file

@ -96,7 +96,7 @@ fn migrate_config(
if options.dry_run && !options.silent {
// Output new content to STDOUT.
println!(
"\nv-----Start TOML for {path:?}-----v\n\n{toml}\n^-----End TOML for {path:?}-----^"
"\nv-----Start TOML for {path:?}-----v\n\n{toml}\n^-----End TOML for {path:?}-----^\n"
);
} else if !options.dry_run {
// Write the new toml configuration.
@ -124,7 +124,23 @@ fn migrate_imports(
Ok(import) => import,
Err(err) => return Err(format!("import error: {err}")),
};
// Keep yaml import if path does not exist.
if !import.exists() {
if options.dry_run {
eprintln!("Keeping yaml config for nonexistent import: {import:?}");
}
new_imports.push(Value::String(import.to_string_lossy().into()));
continue;
}
let new_path = migrate_config(options, &import, recursion_limit - 1)?;
// Print new import path.
if options.dry_run {
println!("Successfully migrated import {import:?} to {new_path:?}");
}
new_imports.push(Value::String(new_path));
}