Skip to content

Commit fa9d974

Browse files
authored
Fix overriding license header bug (#4488)
* Override header to None when path len = 0 * Add regression test * Ensure nightly
1 parent 6a78247 commit fa9d974

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/config/config_type.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ macro_rules! create_config {
299299
Err(msg) => eprintln!("Warning for license template file {:?}: {}",
300300
lt_path, msg),
301301
}
302+
} else {
303+
self.license_template = None;
302304
}
303305
}
304306
}

src/config/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,18 @@ mod test {
491491
assert!(config.license_template.is_some());
492492
}
493493

494+
#[test]
495+
fn test_override_existing_license_with_no_license() {
496+
if !crate::is_nightly_channel!() {
497+
return;
498+
}
499+
let toml = r#"license_template_path = "tests/license-template/lt.txt""#;
500+
let mut config = Config::from_toml(toml, Path::new("")).unwrap();
501+
assert!(config.license_template.is_some());
502+
config.override_value("license_template_path", "");
503+
assert!(config.license_template.is_none());
504+
}
505+
494506
#[test]
495507
fn test_dump_default_config() {
496508
let default_config = format!(

0 commit comments

Comments
 (0)