diff options
Diffstat (limited to 'src/pipeline/mod.rs')
| -rw-r--r-- | src/pipeline/mod.rs | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/pipeline/mod.rs b/src/pipeline/mod.rs index 20648c0..bd37258 100644 --- a/src/pipeline/mod.rs +++ b/src/pipeline/mod.rs @@ -14,6 +14,7 @@ use std::path::PathBuf; use crate::config::Config; use crate::db::{self, builds, Db, Pkgbase}; use crate::db::model::*; +use crate::db::SnapshotRow; use crate::error::{Error, Result}; /// The approved source identity a build must reproduce. @@ -30,20 +31,27 @@ pub struct SourceIdentity { pub epoch: String, pub pkgver: String, pub pkgrel: String, - pub identity_hash: String, } impl SourceIdentity { - pub fn from_candidate(c: &CandidateRow) -> Self { + /// The identity of a build's source, complete on construction (n-1). + /// + /// This used to return a value with `aur_commit` and `recipe_hash` left + /// empty, which `Ctx::new` filled in afterwards if it happened to find the + /// snapshot row — so a `SourceIdentity` was a type whose empty strings could + /// mean either "not filled in yet" or "genuinely unknown", and a new call + /// site that forgot the second half produced a build that silently recorded + /// an empty provenance. The snapshot is an argument now: you cannot build one + /// without it. + pub fn from_candidate(c: &CandidateRow, snapshot: &SnapshotRow) -> Self { Self { - aur_commit: String::new(), - recipe_hash: String::new(), + aur_commit: snapshot.aur_commit.clone(), + recipe_hash: snapshot.recipe_hash.clone(), upstream_pins_json: c.upstream_pins_json.clone(), source_digests_json: c.source_digests_json.clone(), epoch: c.epoch.clone(), pkgver: c.pkgver.clone(), pkgrel: c.pkgrel.clone(), - identity_hash: c.identity_hash.clone(), } } pub fn from_release(r: &ReleaseRow) -> Self { @@ -55,7 +63,6 @@ impl SourceIdentity { epoch: r.epoch.clone(), pkgver: r.pkgver.clone(), pkgrel: r.pkgrel.clone(), - identity_hash: String::new(), } } pub fn version(&self) -> String { @@ -125,12 +132,12 @@ impl Ctx { Some(cid) => { let c = crate::review::candidates::candidate_by_id(db, cid)? .ok_or_else(|| Error::not_found("candidate for build"))?; - let mut si = SourceIdentity::from_candidate(&c); - if let Some(s) = db::snapshot_by_id(db, c.snapshot_id)? { - si.aur_commit = s.aur_commit; - si.recipe_hash = s.recipe_hash; - } - si + // A candidate without its snapshot is a broken row, not a + // candidate with less provenance: say so rather than build + // against an empty commit and hash. + let snap = db::snapshot_by_id(db, c.snapshot_id)? + .ok_or_else(|| Error::not_found("snapshot for candidate"))?; + SourceIdentity::from_candidate(&c, &snap) } None => { let rid = build |
