Fix config reset to use scaffold config files (#14756)

In #14249, `config reset` wasn't updated to use the scaffold config files, so running `config reset` would accidentally reset the user's config to the internal defaults. This PR updates it to use the
scaffold files.
This commit is contained in:
132ikl 2025-01-05 16:18:19 -05:00 committed by GitHub
parent 87a562e24b
commit 1b7fabd1fd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,7 +1,7 @@
use chrono::Local; use chrono::Local;
use nu_engine::command_prelude::*; use nu_engine::command_prelude::*;
use nu_utils::{get_default_config, get_default_env}; use nu_utils::{get_scaffold_config, get_scaffold_env};
use std::io::Write; use std::io::Write;
#[derive(Clone)] #[derive(Clone)]
@ -51,7 +51,7 @@ impl Command for ConfigReset {
if !only_env { if !only_env {
let mut nu_config = config_path.clone(); let mut nu_config = config_path.clone();
nu_config.push("config.nu"); nu_config.push("config.nu");
let config_file = get_default_config(); let config_file = get_scaffold_config();
if !no_backup { if !no_backup {
let mut backup_path = config_path.clone(); let mut backup_path = config_path.clone();
backup_path.push(format!( backup_path.push(format!(
@ -77,7 +77,7 @@ impl Command for ConfigReset {
if !only_nu { if !only_nu {
let mut env_config = config_path.clone(); let mut env_config = config_path.clone();
env_config.push("env.nu"); env_config.push("env.nu");
let config_file = get_default_env(); let config_file = get_scaffold_env();
if !no_backup { if !no_backup {
let mut backup_path = config_path.clone(); let mut backup_path = config_path.clone();
backup_path.push(format!("oldenv-{}.nu", Local::now().format("%F-%H-%M-%S"),)); backup_path.push(format!("oldenv-{}.nu", Local::now().format("%F-%H-%M-%S"),));