Handle missing configurations in `pijul_config`

finchie
Jul 27, 2025, 1:36 PM
HM6QW3CYVZVXOM2K3OT7SQFQGJG3GCDLNYIYAUDEVSJCVCSUZ4CQC

Dependencies

  • [2] ZSFJT4SF Allow remotes to have a different push and pull address
  • [3] 67GIAQEU Handle named remotes in pijul remote and remote delete
  • [4] Z4PPQZUG Refactor `pijul-config` to support layered configuration
  • [5] H4AU6QRP New config for HTTP remotes
  • [*] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).

Change contents

  • edit in pijul-config/src/lib.rs at line 12
    [4.4507]
    [4.4507]
    use log::warn;
  • edit in pijul-config/src/lib.rs at line 74
    [4.5741][2.441:442](),[2.441][2.441:442](),[2.442][4.5742:5903]()
    let global_config_contents = Global::read_contents(&global_config_path)?;
    let local_config_contents = Local::read_contents(&local_config_path)?;
  • edit in pijul-config/src/lib.rs at line 75
    [4.5904][4.5904:6161](),[4.6161][3.16:17](),[3.16][3.16:17]()
    // Validate that the configuration sources are correct
    let global_config = Global::parse_contents(&global_config_path, &global_config_contents)?;
    let local_config = Local::parse_contents(&local_config_path, &local_config_contents)?;
  • replacement in pijul-config/src/lib.rs at line 88
    [4.7080][4.7080:7266]()
    let mut config: Self = Figment::new()
    .merge(Toml::string(&global_config_contents))
    .merge(Toml::string(&local_config_contents))
    .extract()?;
    [4.7080]
    [4.7266]
    let mut layers = Figment::new();
    // 1. Global config
    let global_config = match Global::read_contents(&global_config_path) {
    Ok(contents) => {
    // Parse the config (and make sure it's valid!)
    let global_config = Global::parse_contents(&global_config_path, &contents)?;
    // Add the configuration layer as a string
    layers = layers.merge(Toml::string(&contents));
    Some(global_config)
    }
    Err(error) => {
    warn!("Unable to read global config file: {error:#?}");
    None
    }
    };
    // 2. Local config
    let local_config = match Local::read_contents(&local_config_path) {
    Ok(contents) => {
    // Parse the config (and make sure it's valid!)
    let local_config = Local::parse_contents(&local_config_path, &contents)?;
    // Add the configuration layer as a string
    layers = layers.merge(Toml::string(&contents));
    Some(local_config)
    }
    Err(error) => {
    warn!("Unable to read local config file: {error:#?}");
    None
    }
    };
  • edit in pijul-config/src/lib.rs at line 122
    [4.7267]
    [4.7267]
    // Extract the configuration
    let mut config: Self = layers.extract()?;
  • replacement in pijul-config/src/lib.rs at line 130
    [4.7534][4.7534:7636]()
    config.global_config = Some(global_config);
    config.local_config = Some(local_config);
    [4.7534]
    [4.7636]
    config.global_config = global_config;
    config.local_config = local_config;