summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Duerr <contact@christianduerr.com>2023-12-28 18:57:30 +0100
committerGitHub <noreply@github.com>2023-12-28 21:57:30 +0400
commit81df32af60147941c7d6005cf55ffd14c9665734 (patch)
treebf541f4a444bd90298becaa980e2ac4ed78b1588
parent234fea701c4b8043de3346fd3fdbca84f1593e08 (diff)
downloadalacritty-81df32af60147941c7d6005cf55ffd14c9665734.tar.gz
alacritty-81df32af60147941c7d6005cf55ffd14c9665734.zip
Fix `alacritty migrate` with nonexistent imports
Fixes #7473.
-rw-r--r--CHANGELOG.md4
-rw-r--r--alacritty/src/migrate.rs18
2 files changed, 21 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0534c103..e65f85f3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
diff --git a/alacritty/src/migrate.rs b/alacritty/src/migrate.rs
index 4d632af4..5f47b083 100644
--- a/alacritty/src/migrate.rs
+++ b/alacritty/src/migrate.rs
@@ -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));
}