Skip to content

Commit e0d9b09

Browse files
committed
fix: Modules::is_active() now counts everything that doesn't match submodule.active (if present) as inactive.
1 parent ddb593b commit e0d9b09

File tree

2 files changed

+39
-6
lines changed

2 files changed

+39
-6
lines changed

gix-submodule/src/is_active_platform.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,11 @@ impl IsActivePlatform {
5252
if let Some(val) = config.boolean("submodule", Some(name), "active").transpose()? {
5353
return Ok(val);
5454
};
55-
if let Some(val) = self
56-
.search
57-
.as_mut()
58-
.and_then(|search| search.pattern_matching_relative_path(name, Some(true), attributes))
59-
.map(|m| !m.is_excluded())
60-
{
55+
if let Some(val) = self.search.as_mut().map(|search| {
56+
search
57+
.pattern_matching_relative_path(name, Some(true), attributes)
58+
.map_or(false, |m| !m.is_excluded())
59+
}) {
6160
return Ok(val);
6261
}
6362
Ok(match modules.url(name) {

gix-submodule/tests/file/mod.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,40 @@ mod is_active_platform {
113113
);
114114
Ok(())
115115
}
116+
117+
#[test]
118+
fn pathspecs_matter_even_if_they_do_not_match() -> crate::Result {
119+
let module = multi_modules()?;
120+
assert_eq!(
121+
assume_valid_active_state(
122+
&module,
123+
&gix_config::File::from_str("[submodule]\n active = submodule ")?,
124+
Default::default()
125+
)?,
126+
&[
127+
("submodule", true),
128+
("a/b", false),
129+
(".a/..c", false),
130+
("a/d\\", false),
131+
("a\\e", false)
132+
]
133+
);
134+
assert_eq!(
135+
assume_valid_active_state(
136+
&module,
137+
&gix_config::File::from_str("[submodule]\n active = :!submodule ")?,
138+
Default::default()
139+
)?,
140+
&[
141+
("submodule", false),
142+
("a/b", true),
143+
(".a/..c", true),
144+
("a/d\\", true),
145+
("a\\e", true)
146+
]
147+
);
148+
Ok(())
149+
}
116150
}
117151

118152
mod path {

0 commit comments

Comments
 (0)