use bstr::BStr;
use gix_error::Result;
use crate::IsActivePlatform;
impl IsActivePlatform {
pub fn is_active(
&mut self,
config: &gix_config::File,
name: &BStr,
attributes: &mut dyn FnMut(
&BStr,
gix_pathspec::attributes::glob::pattern::Case,
bool,
&mut gix_pathspec::attributes::search::Outcome,
) -> bool,
) -> Result<bool> {
if let Some(val) = config.boolean(&format!("submodule.{name}.active"))? {
return Ok(val);
}
if let Some(val) = self.search.as_mut().map(|search| {
search
.pattern_matching_relative_path(name, Some(true), attributes)
.is_some_and(|m| !m.is_excluded())
}) {
return Ok(val);
}
Ok(config.string(&format!("submodule.{name}.url")).is_some())
}
}