diff options
Diffstat (limited to 'src/watch/detect.rs')
| -rw-r--r-- | src/watch/detect.rs | 57 |
1 files changed, 5 insertions, 52 deletions
diff --git a/src/watch/detect.rs b/src/watch/detect.rs index d155913..82539b8 100644 --- a/src/watch/detect.rs +++ b/src/watch/detect.rs @@ -3,7 +3,8 @@ use crate::db::{self, *}; use crate::error::Result; use crate::pkgver; use crate::recipe::recipe_from_tree; -use crate::review::candidates::{upsert_candidate, NewCandidate, Upsert}; +use crate::review::candidates::{NewCandidate, Upsert}; +use crate::review::intake; use crate::time; use crate::watch::digests::resolve_sources; use crate::watch::mirror::{read_tree, sync_mirror, Sync}; @@ -67,7 +68,7 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor let mirror = cfg.mirror_path(&pb.name); let report = |outcome: Outcome| CheckReport { pkgbase: pb.name.clone(), head: head.to_string(), outcome }; - let accepted = crate::review::candidates::accepted_for(db, pb)?; + let accepted = db::accepted_release_for(db, pb)?; if let Some(a) = &accepted { if !crate::git::has_commit(&mirror, &a.aur_commit) { db::put_notice_once( @@ -143,8 +144,7 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor }; let Some(base) = accepted else { - let up = upsert_candidate(db, pb, None, &nc)?; - score(db, cfg, pb, &recipe, &digests, None, candidate_id_of(&up)); + let up = intake::record(db, cfg, pb, &recipe, &digests, None, &nc)?; return Ok(report(outcome_of(up))); }; @@ -175,57 +175,10 @@ fn analyse(cfg: &Config, db: &Db, pb: &Pkgbase, head: &str) -> Result<CheckRepor )?; } - let up = upsert_candidate(db, pb, Some(&base), &nc)?; - score(db, cfg, pb, &recipe, &digests, Some(&base), candidate_id_of(&up)); + let up = intake::record(db, cfg, pb, &recipe, &digests, Some(&base), &nc)?; Ok(report(outcome_of(up))) } -fn candidate_id_of(up: &Upsert) -> Option<i64> { - match up { - Upsert::Created { id, .. } | Upsert::Collapsed { id, .. } | Upsert::Superseded { new: id, .. } => Some(*id), - Upsert::PreviouslyRejected | Upsert::Unchanged => None, - } -} - -fn score( - db: &Db, - cfg: &Config, - pb: &Pkgbase, - recipe: &Recipe, - digests: &[SourceDigest], - accepted: Option<&ReleaseRow>, - candidate_id: Option<i64>, -) { - let Some(id) = candidate_id else { return }; - if let Ok(a) = crate::review::risk::assess(db, cfg, recipe, digests, accepted) { - let _ = crate::review::candidates::set_risk(db, id, &a.level, &a.signals); - } - let missing = missing_deps(db, pb, recipe); - let _ = crate::review::candidates::set_missing_deps(db, id, &missing); -} - -fn missing_deps(db: &Db, pb: &Pkgbase, recipe: &Recipe) -> Vec<String> { - let ours = match db::our_package_names(db) { - Ok(o) => o, - Err(_) => return Vec::new(), - }; - let mut out = Vec::new(); - for dep in crate::pkgver::dep_names(&recipe.depends) { - if ours.contains(&dep) || dep == pb.name || recipe.pkgnames.contains(&dep) { - continue; - } - let ours_to_publish = db::get_subscription(db, &dep) - .map(|s| s.is_some()) - .unwrap_or(false) - || db::get_pkgbase(db, &dep).map(|p| p.is_some()).unwrap_or(false); - if ours_to_publish { - out.push(dep); - } - } - out.sort(); - out -} - fn outcome_of(up: Upsert) -> Outcome { match up { Upsert::Created { id, kind } => Outcome::Candidate { id, kind }, |
