rpo 0.1.0-beta.5

Git contribution analysis: commits, file changes, and per-line authorship over time as polars DataFrames
mod helpers;

use helpers::RepoFixture;
use rpo::RepoAnalyzer;

#[test]
fn mailmap_canonicalizes_identity() {
    let f = RepoFixture::new();
    f.write("a.rs", "fn a() {}\n");
    f.commit("Alicia", "alicia@work.com", "add a");
    f.write("b.rs", "fn b() {}\n");
    f.commit("Alicia", "alicia@personal.com", "add b");
    // Map both addresses to a canonical identity.
    f.write(
        ".mailmap",
        "Alicia Canonical <alicia@canonical.com> <alicia@work.com>\n\
         Alicia Canonical <alicia@canonical.com> <alicia@personal.com>\n",
    );
    f.commit("Alicia", "alicia@work.com", "add mailmap");

    let analysis = RepoAnalyzer::open(f.path()).unwrap().all().unwrap();

    let raws: Vec<&str> = analysis
        .commits
        .column("author_email")
        .unwrap()
        .str()
        .unwrap()
        .iter()
        .filter_map(|o| o)
        .collect();
    assert!(raws.contains(&"alicia@work.com"));
    assert!(raws.contains(&"alicia@personal.com"));

    let canon: Vec<&str> = analysis
        .commits
        .column("canonical_author_email")
        .unwrap()
        .str()
        .unwrap()
        .iter()
        .filter_map(|o| o)
        .collect();
    for c in canon {
        assert_eq!(c, "alicia@canonical.com");
    }
}