From 0b3cb443e70b46ec61455255c3ddfc2a26997613 Mon Sep 17 00:00:00 2001 From: aur-build Date: Wed, 18 Nov 2026 07:16:36 +0000 Subject: =?UTF-8?q?watch:=20two-stage=20VCS=20watcher=20=E2=80=94=20ls-rem?= =?UTF-8?q?ote=20probe,=20pkgver()=20resolution,=20pin=20capture=20(=C2=A7?= =?UTF-8?q?5.2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stage A probes every VCS source in source=() with git ls-remote, respecting #commit/#tag/#branch fragments, and returns one UpstreamPin per source. If the tip set equals the accepted release's pins, nothing can have changed and Stage B never runs — the common case costs one round trip per source and no clone. svn/hg have no cheap universal probe, so they are reported as unprobed and force Stage B rather than being silently treated as unchanged. Stage B runs only on movement: it fetches into a persistent vcs_cache (rather than re-cloning a multi-gigabyte upstream daily), runs makepkg --vercheck, and captures the pins from the clone it already has. Results are cached on (pkgbase, recipe_hash, upstream_tip) with a per-pkgbase cooldown, and a process-wide slot cap bounds concurrent resolutions. The resolved epoch:pkgver-pkgrel plus the pins go into identity_hash, so a different commit is a different thing to approve. Also fixes a misclassification the new path exposed: a VCS source's digest is its pin, so upstream movement showed up as an integrity_alert. Integrity events are now restricted to fixed downloads; VCS movement under a frozen pkgver is pin_drift, as §5.2 specifies. New fixtures git-multi (two upstreams) and git-tagged (#tag pin). 10 tests in tests/vcs.rs. --- src/watch/detect.rs | 62 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 10 deletions(-) (limited to 'src/watch/detect.rs') 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 = 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 = 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 = 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, -- cgit v1.2.3