artifactize-core 0.27.0

The library behind artifactize: Artifacts, evals, reviews, the monitor and review models, and the shared operations every interface calls.
Documentation
use super::*;
use crate::monitor::live::Place;

#[tokio::test]
async fn a_detail_tool_refuses_to_run_after_the_worktree_switches_branches() {
    let workspace = crate::test_os::tempdir();
    let root = crate::test_os::canonical(workspace.path());
    std::fs::create_dir(root.join(".artifactize")).unwrap();
    std::fs::write(
        root.join(".artifactize/app.artf"),
        r#"
tool reader = {
  human notes = builtin(op = "read", args = ["@{path self}"])
}

artf app : reader = { path = "notes.md" }
"#,
    )
    .unwrap();
    std::fs::write(root.join("notes.md"), "# Notes").unwrap();
    crate::test_os::git(&root, &["init", "--quiet", "--initial-branch=expected"]);
    let checkout = Place::for_checkout(&root, &crate::repository::identify(&root));
    let artifact = "app".parse().unwrap();
    let sites = crate::config::read_sites(&root).unwrap();
    let app = ArtifactDeclarations::read(&root, &artifact, &sites[&artifact]).unwrap();
    let tool = "reader_notes_app".parse().unwrap();
    let run = || {
        app.run_tool(
            &checkout,
            &tool,
            CancellationToken::new(),
            log::Run::unwatched(),
        )
    };
    assert!(!run().await.unwrap().is_error());
    crate::test_os::git(&root, &["symbolic-ref", "HEAD", "refs/heads/other"]);
    assert_eq!(
        run().await.unwrap_err(),
        "This branch is no longer checked out in the worktree."
    );
}