cargo-governor 1.2.0

Machine-First, LLM-Ready, CI/CD-Native release automation tool for Rust crates
Documentation
//! # cargo-governor
//!
//! Machine-First Release Automation Tool for Rust workspaces.
//!
//! This library provides core functionality for:
//!
//! - **Version Analysis**: Analyzing commits to determine semantic version bumps
//! - **Dependency Management**: Building publication order from dependency graphs
//! - **Changelog Generation**: Creating and updating changelog files
//! - **Risk Assessment**: Evaluating release risks
//!
//! ## Modules
//!
//! - [`analyze_commits`] - Parse and analyze conventional commits
//! - [`analyze_bump_type`] - Determine version bump type from analysis
//! - [`build_dependency_graph`] - Create dependency graph from workspace
//! - [`build_publication_order`] - Determine optimal publish order
//! - [`update_changelog`] - Update CHANGELOG.md with new entries
//!
//! ## Examples
//!
//! ### Analyzing Commits
//!
//! ```
//! use cargo_governor::analyze_commits;
//! use governor_core::domain::commit::Commit;
//! use chrono::Utc;
//!
//! let commits = vec![
//!     Commit::new(
//!         "abc123".to_string(),
//!         "feat: add new feature".to_string(),
//!         "Alice".to_string(),
//!         "alice@example.com".to_string(),
//!         Utc::now(),
//!     ),
//! ];
//!
//! let analysis = analyze_commits(&commits);
//! println!("Breaking: {}, Features: {}, Fixes: {}",
//!     analysis.breaking.len(),
//!     analysis.features.len(),
//!     analysis.fixes.len()
//! );
//! ```
//!
//! ### Determining Version Bump
//!
//! ```
//! use cargo_governor::{analyze_commits, analyze_bump_type};
//! use governor_core::domain::commit::Commit;
//! use governor_core::domain::version::BumpType;
//! use chrono::Utc;
//!
//! let commits = vec![
//!     Commit::new(
//!         "abc123".to_string(),
//!         "feat!: breaking API change".to_string(),
//!         "Alice".to_string(),
//!         "alice@example.com".to_string(),
//!         Utc::now(),
//!     ),
//!     Commit::new(
//!         "def456".to_string(),
//!         "feat: add new feature".to_string(),
//!         "Bob".to_string(),
//!         "bob@example.com".to_string(),
//!         Utc::now(),
//!     ),
//! ];
//!
//! let analysis = analyze_commits(&commits);
//! let bump = analyze_bump_type(&analysis);
//! assert_eq!(bump, BumpType::Major);
//! ```

#![allow(clippy::multiple_crate_versions)] // Allow multiple versions from transitive dependencies

// Include modules needed for testing
pub mod error;

// Include plan module functions that don't depend on CLI
mod services {
    pub mod release {
        pub mod analyze {
            pub mod analysis;
            pub mod bump;
            pub mod risk;

            pub use analysis::{
                analyze_commits, build_breaking_changes, build_features, build_fixes,
            };
            pub use bump::{analyze_bump_type, calculate_confidence, generate_reasoning};
            pub use risk::calculate_risk_assessment;
        }

        pub mod bump {
            pub mod changelog;
            pub mod version;

            pub use changelog::update_changelog;
            pub use version::analyze_commits_for_bump;
        }

        pub mod plan {
            pub mod graph;
            pub mod metadata;
            pub mod order;

            pub use graph::{
                build_dependency_graph, get_dependencies_for, get_graph_stats, get_publish_order,
            };

            pub use order::{
                PublicationCrate, SkippedCrate, build_batches, build_publication_order,
                get_skipped_crates,
            };
        }

        pub mod publish {
            pub mod registry;

            pub use registry::check_if_published;
        }
    }
}

// Re-export analyze module functions for testing
pub use services::release::analyze::{
    analyze_bump_type, analyze_commits, build_breaking_changes, build_features, build_fixes,
    calculate_confidence, calculate_risk_assessment, generate_reasoning,
};

// Re-export bump module functions for testing
pub use services::release::bump::{analyze_commits_for_bump, update_changelog};

// Re-export plan module functions that don't depend on CLI
pub use services::release::plan::{
    PublicationCrate, SkippedCrate, build_batches, build_dependency_graph, build_publication_order,
    get_dependencies_for, get_graph_stats, get_publish_order, get_skipped_crates,
};

// Re-export publish module functions for testing
pub use services::release::publish::check_if_published;

// Re-export error types
pub use error::{CommandExitCode, Error, Result};