cargo-governor 2.0.3

Machine-First, LLM-Ready, CI/CD-Native release automation tool for Rust crates
Documentation
//! Adapter construction helpers for CLI commands.

use std::path::PathBuf;

use governor_cargo::CargoWorkspaceAdapter;
use governor_checkpoint::FileCheckpointStore;
use governor_cratesio::CratesIoRegistry;
use governor_git::{GitAdapter, GitAdapterConfig};

use crate::error::{Error, Result};

pub const fn cargo_adapter() -> CargoWorkspaceAdapter {
    CargoWorkspaceAdapter
}

pub fn registry_adapter() -> CratesIoRegistry {
    CratesIoRegistry::new()
}

pub fn git_adapter(workspace_path: &str) -> Result<GitAdapter> {
    GitAdapter::open(GitAdapterConfig {
        repository_path: Some(PathBuf::from(workspace_path)),
        ..Default::default()
    })
    .map_err(|error| Error::Git(error.to_string()))
}

pub fn checkpoint_store(workspace_path: &str) -> Result<FileCheckpointStore> {
    FileCheckpointStore::new(
        PathBuf::from(workspace_path)
            .join(".cargo-governor")
            .join("checkpoints"),
    )
    .map_err(|error| Error::Config(error.to_string()))
}