summaryrefslogtreecommitdiffstats
path: root/src/watch/detect.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/watch/detect.rs')
-rw-r--r--src/watch/detect.rs62
1 files changed, 52 insertions, 10 deletions
diff --git a/src/watch/detect.rs b/src/watch/detect.rs
index e00a2f9..d5f5c46 100644
--- a/src/watch/detect.rs
+++ b/src/watch/detect.rs
@@ -118,14 +118,47 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
let tree = read_tree(&mirror, head)?;
let recipe = recipe_from_tree(&tree.files)?;
let recipe_hash = tree.recipe_hash();
- let digests = resolve_sources(cfg, db, &mirror, head, &tree, &recipe, &[])?;
- let pins: Vec<UpstreamPin> = Vec::new(); // P1 fills this in for VCS sources
+
+ // §5.2, the two-stage funnel. Stage A is one `ls-remote` per VCS source and
+ // costs no clone; if the tip set is what the accepted release was built
+ // from, nothing can have changed and Stage B never runs.
+ let has_vcs = recipe.source_entries.iter().any(|e| e.is_vcs());
+ let accepted_pins: Vec<UpstreamPin> = accepted.as_ref().map(|a| a.pins()).unwrap_or_default();
+ // A recipe with no VCS sources states its own version; there is nothing to
+ // probe and nothing to resolve.
+ let stage_a = if has_vcs {
+ Some(crate::watch::upstream::probe(&recipe, &accepted_pins)?)
+ } else {
+ None
+ };
+ let resolved = if !has_vcs {
+ None
+ } else if stage_a.as_ref().unwrap().needs_stage_b() {
+ crate::watch::upstream::resolve(cfg, db, pb, &recipe, &recipe_hash, stage_a.as_ref().unwrap())?
+ } else {
+ // Upstream has not moved. The version we serve is still the answer, and
+ // reusing its pins is what makes the next pass cheap too.
+ accepted.as_ref().map(|a| crate::watch::upstream::StageB {
+ epoch: a.epoch.clone(),
+ pkgver: a.pkgver.clone(),
+ pkgrel: a.pkgrel.clone(),
+ pins: accepted_pins.clone(),
+ cached: true,
+ })
+ };
+ // For a VCS package the literal `pkgver=` is frozen; the resolved one is the
+ // only version a consumer could actually install.
+ let (epoch, pkgver, pkgrel, pins) = match &resolved {
+ Some(r) => (r.epoch.clone(), r.pkgver.clone(), r.pkgrel.clone(), r.pins.clone()),
+ None => (recipe.epoch.clone(), recipe.pkgver.clone(), recipe.pkgrel.clone(), Vec::new()),
+ };
+ let digests = resolve_sources(cfg, db, &mirror, head, &tree, &recipe, &pins)?;
let identity = Identity {
aur_commit: head.to_string(),
- epoch: recipe.epoch.clone(),
- pkgver: recipe.pkgver.clone(),
- pkgrel: recipe.pkgrel.clone(),
+ epoch: epoch.clone(),
+ pkgver: pkgver.clone(),
+ pkgrel: pkgrel.clone(),
upstream_pins: pins.clone(),
source_digests: digests.clone(),
};
@@ -141,9 +174,9 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor
let nc = NewCandidate {
snapshot_id: snap_id,
- epoch: recipe.epoch.clone(),
- pkgver: recipe.pkgver.clone(),
- pkgrel: recipe.pkgrel.clone(),
+ epoch: epoch.clone(),
+ pkgver: pkgver.clone(),
+ pkgrel: pkgrel.clone(),
upstream_pins_json: serde_json::to_string(&pins)?,
source_digests_json: serde_json::to_string(&digests)?,
identity_hash: identity_hash.clone(),
@@ -216,9 +249,19 @@ fn non_publishable(
// A local source is part of the recipe: when its bytes move, that *is* the
// recipe drift, not an integrity event. The integrity alert is specifically
// "the bytes upstream serves no longer match what we built" (§5.3).
+ // A VCS source's digest *is* its pin, so upstream moving shows up there too
+ // — but that is ordinary drift, handled by the pin check below, not an
+ // integrity event. Integrity means "the bytes we built are gone and the
+ // version says nothing moved", which only applies to fixed downloads.
+ let vcs_indices: std::collections::BTreeSet<usize> = recipe
+ .source_entries
+ .iter()
+ .filter(|e| e.is_vcs())
+ .map(|e| e.index)
+ .collect();
let changed_remote: Vec<&SourceDigest> = new_digests
.iter()
- .filter(|n| n.kind != "local")
+ .filter(|n| n.kind != "local" && !vcs_indices.contains(&n.index))
.filter(|n| match old_digests.iter().find(|o| o.index == n.index) {
Some(o) => o.digest != n.digest,
None => true,
@@ -271,7 +314,6 @@ fn non_publishable(
}
// The recipe drifted under a static version: the maintainer probably forgot
// to bump pkgrel, and the user should know.
- let _ = recipe;
db::put_notice_once(
&db.writer,
pb.id,