summaryrefslogtreecommitdiffstats
path: root/src/review/risk.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/review/risk.rs')
-rw-r--r--src/review/risk.rs42
1 files changed, 3 insertions, 39 deletions
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.