summaryrefslogtreecommitdiffstats
path: root/src/review
diff options
context:
space:
mode:
Diffstat (limited to 'src/review')
-rw-r--r--src/review/approve.rs54
-rw-r--r--src/review/diff.rs39
-rw-r--r--src/review/risk.rs42
3 files changed, 37 insertions, 98 deletions
diff --git a/src/review/approve.rs b/src/review/approve.rs
index 208e8e2..e5f446f 100644
--- a/src/review/approve.rs
+++ b/src/review/approve.rs
@@ -110,15 +110,14 @@ pub fn approve(
candidates::resolve_in(tx, id, CandidateState::Approved, &at)?;
db::audit_in(
tx,
- &db::AuditEntry {
- at: &at,
- actor_kind: "human",
- actor: &actor,
- action: "approve",
- entity: "candidate",
- entity_id: &id.to_string(),
- detail: serde_json::json!({"approval": approval_id, "identity": ih, "pkgbase_id": subject.pkgbase_id}),
- },
+ &db::AuditEntry::human(
+ &at,
+ &actor,
+ "approve",
+ "candidate",
+ &id.to_string(),
+ serde_json::json!({"approval": approval_id, "identity": ih, "pkgbase_id": subject.pkgbase_id}),
+ ),
)?;
Ok(Ok(Approval {
id: approval_id,
@@ -151,15 +150,17 @@ pub fn reject(db: &Db, actor: &str, candidate_id: i64, note: &str) -> Result<()>
candidates::resolve_in(tx, candidate_id, CandidateState::Rejected, &at)?;
db::audit_in(
tx,
- &db::AuditEntry {
- at: &at,
- actor_kind: "human",
- actor: &actor,
- action: "reject",
- entity: "candidate",
- entity_id: &candidate_id.to_string(),
- detail: serde_json::json!({"note": note}),
- },
+ &db::AuditEntry::human(
+ &at,
+ &actor,
+ "reject",
+ "candidate",
+ &candidate_id.to_string(),
+ // The identity hash, not only the note: "why was this rejected"
+ // is unanswerable if the row does not say which bytes were on
+ // screen (ยง11).
+ serde_json::json!({"identity": identity, "note": note}),
+ ),
)?;
Ok(())
})
@@ -276,15 +277,14 @@ pub fn withdraw(db: &Db, actor: &str, release_id: i64, reason: &str) -> Result<(
db::withdraw_release_in(tx, release_id)?;
db::audit_in(
tx,
- &db::AuditEntry {
- at: &at,
- actor_kind: "human",
- actor: &actor,
- action: "withdraw",
- entity: "release",
- entity_id: &release_id.to_string(),
- detail: serde_json::json!({"reason": reason}),
- },
+ &db::AuditEntry::human(
+ &at,
+ &actor,
+ "withdraw",
+ "release",
+ &release_id.to_string(),
+ serde_json::json!({"release": release_id, "reason": reason}),
+ ),
)?;
Ok(())
})
diff --git a/src/review/diff.rs b/src/review/diff.rs
index 1196406..629258c 100644
--- a/src/review/diff.rs
+++ b/src/review/diff.rs
@@ -89,8 +89,8 @@ fn source_delta(old: &Recipe, new: &Recipe) -> Panel {
body.push_str(&format!("- {s}\n"));
}
}
- let old_hosts = hosts(&old.source);
- let new_hosts = hosts(&new.source);
+ let old_hosts = crate::urlutil::hosts(&old.source);
+ let new_hosts = crate::urlutil::hosts(&new.source);
for h in new_hosts.difference(&old_hosts) {
body.push_str(&format!("! new source host: {h}\n"));
}
@@ -190,40 +190,15 @@ fn install_delta(old: &Recipe, new: &Recipe) -> Panel {
(Some(a), Some(b)) if a != b => body.push_str(&format!("! install script changed: {a} -> {b}\n")),
_ => {}
}
- if old.pkgbuild != new.pkgbuild {
- // The recipe diff shows the text; here we call out only whether the
- // executable part moved, which is what actually runs.
- let f = |t: &str| {
- t.lines()
- .filter(|l| {
- let l = l.trim_start();
- l.starts_with("build()")
- || l.starts_with("package")
- || l.starts_with("prepare()")
- || l.starts_with("check()")
- })
- .collect::<Vec<_>>()
- .join("\n")
- };
- if f(&old.pkgbuild) != f(&new.pkgbuild) {
- body.push_str("! build()/package() bodies changed โ€” this is code that runs here and on every installer\n");
- }
+ if crate::recipe::bodies_changed(&old.pkgbuild, &new.pkgbuild) {
+ // The recipe diff shows the text; this panel calls out that the
+ // executable part moved, which is what actually runs โ€” on this machine
+ // and on every machine that installs the result.
+ body.push_str("! build()/package() bodies changed โ€” this is code that runs here and on every installer\n");
}
Panel { name: "install", title: "Install-script delta", body }
}
-fn hosts(sources: &[String]) -> std::collections::BTreeSet<String> {
- sources
- .iter()
- .filter_map(|s| {
- let s = s.rsplit("::").next().unwrap_or(s);
- let s = s.rsplit('+').next().unwrap_or(s);
- let rest = s.split("://").nth(1)?;
- rest.split('/').next().map(|h| h.to_string())
- })
- .collect()
-}
-
fn version_delta(base: Option<&ReleaseRow>, c: &CandidateRow) -> Panel {
let mut body = String::new();
match base {
diff --git a/src/review/risk.rs b/src/review/risk.rs
index 0c09841..73f9be7 100644
--- a/src/review/risk.rs
+++ b/src/review/risk.rs
@@ -126,8 +126,8 @@ fn compare_recipes(old: &Recipe, new: &Recipe, s: &mut SignalSet) {
s.add("downgrade", level::MEDIUM);
}
// Sources: added/removed entries and host changes.
- let old_hosts = hosts(&old.source);
- let new_hosts = hosts(&new.source);
+ let old_hosts = crate::urlutil::hosts(&old.source);
+ let new_hosts = crate::urlutil::hosts(&new.source);
for h in &new_hosts {
if !old_hosts.contains(h) {
s.add(&format!("new-source-host:{h}"), level::HIGH);
@@ -164,7 +164,7 @@ fn compare_recipes(old: &Recipe, new: &Recipe, s: &mut SignalSet) {
s.add("checkdepends-removed", level::MEDIUM);
}
// Did the executable part of the recipe change, or only metadata?
- if body_changed(&old.pkgbuild, &new.pkgbuild) {
+ if crate::recipe::bodies_changed(&old.pkgbuild, &new.pkgbuild) {
s.add("recipe-code-changed", level::HIGH);
}
if old.install != new.install {
@@ -192,42 +192,6 @@ fn compare_digests(
}
}
-/// True when the diff touches a `build()`/`package()`/`prepare()`/`check()`
-/// body rather than only the variable assignments above them.
-fn body_changed(old_src: &str, new_src: &str) -> bool {
- fn bodies(text: &str) -> String {
- let mut out = String::new();
- let mut inside = false;
- for line in text.lines() {
- let t = line.trim_start();
- if t.starts_with("build()")
- || t.starts_with("package")
- || t.starts_with("prepare()")
- || t.starts_with("check()")
- {
- inside = true;
- }
- if inside {
- out.push_str(t);
- out.push('\n');
- }
- }
- out
- }
- bodies(old_src) != bodies(new_src)
-}
-
-fn hosts(sources: &[String]) -> std::collections::BTreeSet<String> {
- sources
- .iter()
- .filter_map(|s| {
- let s = s.rsplit("::").next().unwrap_or(s);
- let s = s.rsplit('+').next().unwrap_or(s);
- let rest = s.split("://").nth(1)?;
- rest.split('/').next().map(|h| h.to_string())
- })
- .collect()
-}
fn upstream_touches_build_system(cfg: &crate::config::Config, pb: &Pkgbase, from: &str, to: &str) -> bool {
// Best-effort: if we have the upstream clone cached we can ask it directly.