| @@ -12,34 +12,19 @@ pub enum Error { · 11 unmodified lines |
| 12 | 12 | ParsePattern(#[from] gix_pathspec::parse::Error), |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | | −/// |
| 16 | | −pub mod is_active { |
| 17 | | − /// The error returned by the iterator of [File::names_and_active_state](crate::File::names_and_active_state()). |
| 18 | | − #[derive(Debug, thiserror::Error)] |
| 19 | | − #[allow(missing_docs)] |
| 20 | | − pub enum Error { |
| 21 | | − #[error("The value of the 'active' field of a submodule could not be decoded")] |
| 22 | | − ActiveField(#[from] gix_config::value::Error), |
| 23 | | − #[error(transparent)] |
| 24 | | − Url(#[from] crate::config::url::Error), |
| 25 | | − } |
| 26 | | −} |
| 27 | | − |
| 28 | 15 | impl IsActivePlatform { |
| 29 | 16 | /// Returns `true` if the submodule named `name` is active or `false` otherwise. |
| 30 | | − /// `modules` is the instance that [is_active_platform()](crate::File::is_active_platform()) was called on, and |
| 31 | | − /// `config` is the configuration that was passed there as well. |
| 32 | | − /// `attributes(relative_path, case, is_dir, outcome)` provides a way to resolve the attributes mentioned in `submodule.active` pathspecs |
| 33 | | − /// that are evaluated in the platforms git configuration. |
| 17 | + /// `config` is the configuration that was passed to the originating [modules file](crate::File). |
| 18 | + /// `attributes(relative_path, case, is_dir, outcome)` provides a way to resolve the attributes mentioned |
| 19 | + /// in `submodule.active` pathspecs that are evaluated in the platforms git configuration. |
| 34 | 20 | /// |
| 35 | 21 | /// A submodule's active state is determined in the following order |
| 36 | 22 | /// |
| 37 | | − /// * it's `submodule.<name>.active` configuration is set |
| 23 | + /// * it's `submodule.<name>.active` is set in `config` |
| 38 | 24 | /// * it matches a `submodule.active` pathspec either positively or negatively via `:!<spec>` |
| 39 | | − /// * it's active if it has a `url` |
| 25 | + /// * it's active if it has any `url` set in `config` |
| 40 | 26 | pub fn is_active( |
| 41 | 27 | &mut self, |
| 42 | | − modules: &crate::File, |
| 43 | 28 | config: &gix_config::File<'static>, |
| 44 | 29 | name: &BStr, |
| 45 | 30 | attributes: impl FnMut( |
| @@ -48,7 +33,7 @@ impl IsActivePlatform { · 2 unmodified lines |
| 48 | 33 | bool, |
| 49 | 34 | &mut gix_pathspec::attributes::search::Outcome, |
| 50 | 35 | ) -> bool, |
| 51 | | − ) -> Result<bool, is_active::Error> { |
| 36 | + ) -> Result<bool, gix_config::value::Error> { |
| 52 | 37 | if let Some(val) = config.boolean("submodule", Some(name), "active").transpose()? { |
| 53 | 38 | return Ok(val); |
| 54 | 39 | }; |
| @@ -59,10 +44,6 @@ impl IsActivePlatform { · 4 unmodified lines |
| 59 | 44 | }) { |
| 60 | 45 | return Ok(val); |
| 61 | 46 | } |
| 62 | | − Ok(match modules.url(name) { |
| 63 | | − Ok(_) => true, |
| 64 | | − Err(crate::config::url::Error::Missing { .. }) => false, |
| 65 | | − Err(err) => return Err(err.into()), |
| 66 | | − }) |
| 47 | + Ok(config.string("submodule", Some(name), "url").is_some()) |
| 67 | 48 | } |
| 68 | 49 | } |