Skip to content

Commit c2cbe8b

Browse files
committed
apply nit notes
Signed-off-by: onur-ozkan <[email protected]>
1 parent ad2e4a4 commit c2cbe8b

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

bootstrap.example.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
# Inherits configuration values from different configuration files (a.k.a. config extensions).
2323
# Supports absolute paths, and uses the current directory (where the bootstrap was invoked)
2424
# as the base if the given path is not absolute.
25+
#
26+
# The overriding logic follows a right-to-left order. For example, in `include = ["a.toml", "b.toml"]`,
27+
# extension `b.toml` overrides `a.toml`. Also, parent extensions always overrides the inner ones.
2528
#include = []
2629

2730
# Keeps track of major changes made to this configuration.

src/bootstrap/src/core/config/config.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -771,12 +771,11 @@ impl Merge for TomlConfig {
771771
}
772772
}
773773

774-
for include_path in include.clone().unwrap_or_default() {
774+
for include_path in include.clone().unwrap_or_default().iter().rev() {
775+
let include_path = include_path.canonicalize().unwrap();
776+
775777
let included_toml = Config::get_toml(&include_path).unwrap_or_else(|e| {
776-
eprintln!(
777-
"ERROR: Failed to parse default config profile at '{}': {e}",
778-
include_path.display()
779-
);
778+
eprintln!("ERROR: Failed to parse '{}': {e}", include_path.display());
780779
exit!(2);
781780
});
782781

@@ -786,7 +785,7 @@ impl Merge for TomlConfig {
786785
include_path.display()
787786
);
788787

789-
self.merge(included_extensions, included_toml, ReplaceOpt::Override);
788+
self.merge(included_extensions, included_toml, ReplaceOpt::IgnoreDuplicate);
790789

791790
included_extensions.remove(&include_path);
792791
}
@@ -1608,6 +1607,14 @@ impl Config {
16081607
toml.profile = Some("dist".into());
16091608
}
16101609

1610+
for include_path in toml.include.clone().unwrap_or_default().iter().rev() {
1611+
let included_toml = get_toml(include_path).unwrap_or_else(|e| {
1612+
eprintln!("ERROR: Failed to parse '{}': {e}", include_path.display());
1613+
exit!(2);
1614+
});
1615+
toml.merge(&mut Default::default(), included_toml, ReplaceOpt::IgnoreDuplicate);
1616+
}
1617+
16111618
if let Some(include) = &toml.profile {
16121619
// Allows creating alias for profile names, allowing
16131620
// profiles to be renamed while maintaining back compatibility
@@ -1632,17 +1639,6 @@ impl Config {
16321639
toml.merge(&mut Default::default(), included_toml, ReplaceOpt::IgnoreDuplicate);
16331640
}
16341641

1635-
for include_path in toml.include.clone().unwrap_or_default() {
1636-
let included_toml = get_toml(&include_path).unwrap_or_else(|e| {
1637-
eprintln!(
1638-
"ERROR: Failed to parse default config profile at '{}': {e}",
1639-
include_path.display()
1640-
);
1641-
exit!(2);
1642-
});
1643-
toml.merge(&mut Default::default(), included_toml, ReplaceOpt::Override);
1644-
}
1645-
16461642
let mut override_toml = TomlConfig::default();
16471643
for option in flags.set.iter() {
16481644
fn get_table(option: &str) -> Result<TomlConfig, toml::de::Error> {

0 commit comments

Comments
 (0)