fn find_uncommitted_changes()

in focus/operations/src/detect_build_graph_changes.rs [45:67]


fn find_uncommitted_changes(app: Arc<App>, repo: &Path) -> Result<Vec<PathBuf>> {
    let output =
        git_helper::run_consuming_stdout(repo, ["status", "--porcelain", "--no-renames"], app)?;
    let mut build_involved_changed_paths = Vec::<PathBuf>::new();
    for line in output.lines() {
        let mut tokens = line.split_ascii_whitespace().take(2);
        let status = tokens.next();
        if status.is_none() {
            bail!("missing first token parsing line {}", &line);
        }
        let path = tokens.next();
        if path.is_none() {
            bail!("missing second token parsing line {}", &line);
        }
        let parsed = PathBuf::from(path.unwrap());
        if paths::is_relevant_to_build_graph(parsed.as_path()) {
            info!(path = ?parsed, "Uncommitted file");
            build_involved_changed_paths.push(parsed);
        }
    }

    Ok(build_involved_changed_paths)
}