diff options
Diffstat (limited to 'src/review/diff.rs')
| -rw-r--r-- | src/review/diff.rs | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/src/review/diff.rs b/src/review/diff.rs index 519d9ae..42467f0 100644 --- a/src/review/diff.rs +++ b/src/review/diff.rs @@ -7,11 +7,9 @@ use crate::git; pub struct Panel { pub name: &'static str, pub title: &'static str, - /// Unified-diff text, or a readable rendering for panels that are not diffs. pub body: String, } -/// Everything a reviewer needs for one candidate. pub fn panels(cfg: &Config, db: &Db, c: &CandidateRow, base: Option<&ReleaseRow>) -> Result<Vec<Panel>> { let mut out = Vec::new(); let snap = db::snapshot_by_id(db, c.snapshot_id)?; @@ -44,8 +42,6 @@ pub fn panels(cfg: &Config, db: &Db, c: &CandidateRow, base: Option<&ReleaseRow> out.push(install_delta(old, new)); } } else { - // §7.1b first_introduction: no diff pane. The full recipe is rendered - // readably instead, by the template. out.push(Panel { name: "recipe_full", title: "Full recipe", @@ -57,7 +53,6 @@ pub fn panels(cfg: &Config, db: &Db, c: &CandidateRow, base: Option<&ReleaseRow> Ok(out) } -/// The recipe a candidate recorded, if we kept the snapshot. fn recipe_of(db: &Db, snapshot_id: Option<i64>) -> Option<Recipe> { let id = snapshot_id?; let snap = db::snapshot_by_id(db, id).ok().flatten()?; @@ -68,8 +63,6 @@ fn candidate_snapshot_id(db: &Db, candidate_id: i64) -> Option<i64> { db::candidate_snapshot_id(db, candidate_id).ok().flatten() } -/// `source=()` entries added, removed, or moved to a different host (§6). A new -/// host is the classic supply-chain shape and must be impossible to miss. fn source_delta(old: &Recipe, new: &Recipe) -> Panel { let mut body = String::new(); for s in &new.source { @@ -90,7 +83,6 @@ fn source_delta(old: &Recipe, new: &Recipe) -> Panel { for h in old_hosts.difference(&new_hosts) { body.push_str(&format!("! source host gone: {h}\n")); } - // A declared checksum that became SKIP is a weakening, not a change. for (i, sum) in new.sha256sums.iter().enumerate() { if sum.eq_ignore_ascii_case("SKIP") { match old.sha256sums.get(i) { @@ -110,8 +102,6 @@ fn source_delta(old: &Recipe, new: &Recipe) -> Panel { Panel { name: "sources", title: "Source delta", body } } -/// Dependency changes, resolved against our own index where we can say what it -/// means: "this will pull in a package we have never published". fn dependency_delta(old: &Recipe, new: &Recipe) -> Panel { let mut body = String::new(); for (label, o, n) in [ @@ -137,7 +127,6 @@ fn dependency_delta(old: &Recipe, new: &Recipe) -> Panel { Panel { name: "deps", title: "Dependency delta", body } } -/// Everything that changes *how* it is built rather than what is built. fn build_env_delta(old: &Recipe, new: &Recipe) -> Panel { let mut body = String::new(); for o in &new.options { @@ -174,7 +163,6 @@ fn build_env_delta(old: &Recipe, new: &Recipe) -> Panel { Panel { name: "buildenv", title: "Build-env delta", body } } -/// `.install` hooks are arbitrary code that runs on every consumer machine. fn install_delta(old: &Recipe, new: &Recipe) -> Panel { let mut body = String::new(); match (&old.install, &new.install) { @@ -184,9 +172,6 @@ fn install_delta(old: &Recipe, new: &Recipe) -> Panel { _ => {} } 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 } @@ -269,7 +254,6 @@ fn short(s: &str) -> String { if s.len() > 12 { s[..12].to_string() } else { s.to_string() } } -/// Flatten the rendered panels into one canonical string. pub fn render_text(ps: &[Panel]) -> String { let mut s = String::new(); for p in ps { @@ -278,12 +262,10 @@ pub fn render_text(ps: &[Panel]) -> String { s } -/// `diff_digest`: hash of the exact rendered diff the human was shown (§7.2). pub fn diff_digest(ps: &[Panel]) -> String { crate::hash::hex_str(&render_text(ps)) } -/// The recipe text a reviewer reads for a first introduction (§7.1b). pub fn full_recipe_text(db: &Db, c: &CandidateRow) -> Result<String> { let snap = db::snapshot_by_id(db, c.snapshot_id)?; let snap = snap.ok_or_else(|| crate::error::Error::not_found("snapshot missing"))?; @@ -291,9 +273,6 @@ pub fn full_recipe_text(db: &Db, c: &CandidateRow) -> Result<String> { Ok(r.pkgbuild) } -/// Render the panels, store the resulting `diff_digest` on the candidate, and -/// hand it back. The approve POST must echo this value, which is what makes -/// "we build exactly what was displayed" checkable (§7.1a). pub fn render_and_store(db: &Db, cfg: &Config, c: &CandidateRow) -> Result<String> { let base = match c.base_release_id { Some(id) => db::release_by_id(db, id)?, @@ -305,7 +284,6 @@ pub fn render_and_store(db: &Db, cfg: &Config, c: &CandidateRow) -> Result<Strin Ok(digest) } -/// Re-render for a 409 response: show the reviewer what the candidate is now. pub fn render_current(db: &Db, cfg: &Config, c: &CandidateRow) -> Result<(String, String)> { let base = match c.base_release_id { Some(id) => db::release_by_id(db, id)?, |
