Skip to main content

perfgate_app/
blame.rs

1use anyhow::Context;
2use perfgate_domain::BinaryBlame;
3use std::fs;
4use std::path::PathBuf;
5
6pub struct BlameRequest {
7    pub baseline_lock: PathBuf,
8    pub current_lock: PathBuf,
9}
10
11pub struct BlameOutcome {
12    pub blame: BinaryBlame,
13}
14
15pub struct BlameUseCase;
16
17impl BlameUseCase {
18    pub fn execute(&self, req: BlameRequest) -> anyhow::Result<BlameOutcome> {
19        let baseline_content = fs::read_to_string(&req.baseline_lock)
20            .with_context(|| format!("failed to read baseline lockfile {:?}", req.baseline_lock))?;
21        let current_content = fs::read_to_string(&req.current_lock)
22            .with_context(|| format!("failed to read current lockfile {:?}", req.current_lock))?;
23
24        let blame = perfgate_domain::compare_lockfiles(&baseline_content, &current_content);
25
26        Ok(BlameOutcome { blame })
27    }
28}