diff options
Diffstat (limited to 'src/watch')
| -rw-r--r-- | src/watch/mirror.rs | 14 | ||||
| -rw-r--r-- | src/watch/mod.rs | 5 | ||||
| -rw-r--r-- | src/watch/upstream.rs | 28 |
3 files changed, 46 insertions, 1 deletions
diff --git a/src/watch/mirror.rs b/src/watch/mirror.rs index 07a60c0..d7c793b 100644 --- a/src/watch/mirror.rs +++ b/src/watch/mirror.rs @@ -14,7 +14,21 @@ pub enum Sync { Cloned { head: String }, } +/// Detection calls it to move the mirror; the test that pins it drives a real sync. +/// +/// Module-internal in a production build, `pub` only under `test-support`: +/// one body behind two visibility declarations, exactly one of which compiles. +#[cfg(feature = "test-support")] pub fn sync_mirror(cfg: &Config, db: &Db, name: &str, url: &str) -> Result<Sync> { + sync_mirror_impl(cfg, db, name, url) +} + +#[cfg(not(feature = "test-support"))] +pub(crate) fn sync_mirror(cfg: &Config, db: &Db, name: &str, url: &str) -> Result<Sync> { + sync_mirror_impl(cfg, db, name, url) +} + +fn sync_mirror_impl(cfg: &Config, db: &Db, name: &str, url: &str) -> Result<Sync> { let mirror = cfg.mirror_path(name); let known_head = db::get_pkgbase(db, name)?.and_then(|p| p.aur_head.clone()); diff --git a/src/watch/mod.rs b/src/watch/mod.rs index 839596a..46ef55a 100644 --- a/src/watch/mod.rs +++ b/src/watch/mod.rs @@ -7,5 +7,8 @@ pub mod staleness; pub mod upstream; pub use detect::{check_pkgbase, Outcome}; -pub use mirror::sync_mirror; +// `mirror::sync_mirror` used to be re-exported here. Nothing used the alias — +// `detect.rs` and `tests/detect.rs` both go through `watch::mirror` directly — +// and a re-export of a conditionally-visible item has to be split by feature +// too, so the dead alias is simply gone. pub use scheduler::spawn_scheduler; diff --git a/src/watch/upstream.rs b/src/watch/upstream.rs index 002d72b..c3e4954 100644 --- a/src/watch/upstream.rs +++ b/src/watch/upstream.rs @@ -17,12 +17,40 @@ pub struct StageA { } impl StageA { + /// Detection consults it; the VCS test that asserts it needs a real mirror. + /// + /// Module-internal in a production build, `pub` only under `test-support`: + /// one body behind two visibility declarations, exactly one of which compiles. + #[cfg(feature = "test-support")] pub fn needs_stage_b(&self) -> bool { + Self::needs_stage_b_impl(self) + } + + #[cfg(not(feature = "test-support"))] + pub(crate) fn needs_stage_b(&self) -> bool { + Self::needs_stage_b_impl(self) + } + + fn needs_stage_b_impl(&self) -> bool { self.moved || !self.unprobed.is_empty() } } +/// Detection calls it on every expensive poll; the tests that pin it need a fixture. +/// +/// Module-internal in a production build, `pub` only under `test-support`: +/// one body behind two visibility declarations, exactly one of which compiles. +#[cfg(feature = "test-support")] pub fn probe(recipe: &Recipe, accepted: &[UpstreamPin]) -> Result<StageA> { + probe_impl(recipe, accepted) +} + +#[cfg(not(feature = "test-support"))] +pub(crate) fn probe(recipe: &Recipe, accepted: &[UpstreamPin]) -> Result<StageA> { + probe_impl(recipe, accepted) +} + +fn probe_impl(recipe: &Recipe, accepted: &[UpstreamPin]) -> Result<StageA> { let mut pins = Vec::new(); let mut unprobed = Vec::new(); for entry in recipe.source_entries.iter().filter(|e| e.is_vcs()) { |
