summaryrefslogtreecommitdiffstats
path: root/tests/common
diff options
context:
space:
mode:
authoraur-build <aur-build@localhost>2026-11-18 07:16:36 +0000
committeraur-build <aur-build@localhost>2026-11-18 07:16:36 +0000
commit0b3cb443e70b46ec61455255c3ddfc2a26997613 (patch)
tree457d5e0bf3b1733b79829de3c146e1cabcc85e8c /tests/common
parentd7c386a703a9b69211d83854547218d6e1da9a51 (diff)
downloadaur-build-0b3cb443e70b46ec61455255c3ddfc2a26997613.tar.gz
aur-build-0b3cb443e70b46ec61455255c3ddfc2a26997613.zip
watch: two-stage VCS watcher — ls-remote probe, pkgver() resolution, pin capture (§5.2)
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.
Diffstat (limited to 'tests/common')
-rw-r--r--tests/common/mod.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 0dc5396..d2582c9 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -245,10 +245,13 @@ pub fn materialize_fixture(root: &Path, name: &str) -> Fixture {
std::fs::create_dir_all(&aur).unwrap();
let upstream = root.join(format!("upstream/{name}"));
+ let upstream2 = root.join(format!("upstream/{name}-2"));
let subs = [
("@AUR_DIR@".to_string(), data.display().to_string()),
("@UPSTREAM_DIR@".to_string(), upstream.display().to_string()),
+ ("@UPSTREAM2_DIR@".to_string(), upstream2.display().to_string()),
];
+ let mut has_upstream2 = false;
let mut recipe_files: Vec<(String, String)> = Vec::new();
let mut has_upstream_ref = false;
@@ -261,6 +264,7 @@ pub fn materialize_fixture(root: &Path, name: &str) -> Fixture {
let body = std::fs::read_to_string(&path).unwrap_or_default();
let body = subs.iter().fold(body, |b, (from, to)| b.replace(from, to));
has_upstream_ref |= body.contains(&upstream.display().to_string());
+ has_upstream2 |= body.contains(&upstream2.display().to_string());
if matches!(fname.as_str(), "payload.bin" | "data.bin") {
std::fs::write(data.join(&fname), &body).unwrap();
} else {
@@ -270,6 +274,16 @@ pub fn materialize_fixture(root: &Path, name: &str) -> Fixture {
if has_upstream_ref {
make_git_repo(&upstream, &[("README", "upstream\n")], "upstream: initial");
}
+ if has_upstream2 {
+ make_git_repo(&upstream2, &[("README", "second upstream\n")], "upstream: initial");
+ }
+ // A `#tag=v1` source needs the tag to exist.
+ if std::fs::read_to_string(src.join("PKGBUILD"))
+ .unwrap_or_default()
+ .contains("#tag=")
+ {
+ git(&upstream, &["tag", "v1"]);
+ }
make_git_repo(
&aur,
&recipe_files.iter().map(|(n, b)| (n.as_str(), b.as_str())).collect::<Vec<_>>(),
@@ -282,6 +296,7 @@ pub fn materialize_fixture(root: &Path, name: &str) -> Fixture {
data,
manifest,
upstream: has_upstream_ref.then_some(upstream),
+ upstream2: has_upstream2.then_some(upstream2),
}
}
@@ -292,6 +307,8 @@ pub struct Fixture {
pub data: PathBuf,
pub manifest: PathBuf,
pub upstream: Option<PathBuf>,
+ /// A second upstream repo, for pkgbases that build from two of them.
+ pub upstream2: Option<PathBuf>,
}
impl Fixture {
@@ -333,6 +350,24 @@ impl Fixture {
git(&up, &["rev-parse", "HEAD"])
}
+ /// Add a commit to the second upstream repo.
+ pub fn upstream2_commit(&self, body: &str) -> String {
+ let up = self.upstream2.clone().expect("fixture has no second upstream repo");
+ git_add_commit(&up, &[(("README"), body)], body);
+ git(&up, &["rev-parse", "HEAD"])
+ }
+
+ /// HEAD of the (first) upstream repo.
+ pub fn upstream_head(&self) -> String {
+ let up = self.upstream.clone().expect("fixture has no upstream repo");
+ git(&up, &["rev-parse", "HEAD"])
+ }
+
+ pub fn upstream2_head(&self) -> String {
+ let up = self.upstream2.clone().expect("fixture has no second upstream repo");
+ git(&up, &["rev-parse", "HEAD"])
+ }
+
pub fn manifest_json(&self) -> serde_json::Value {
serde_json::from_str(&std::fs::read_to_string(&self.manifest).unwrap()).unwrap()
}