gitflow-core 2.0.0

gf 核心库:细粒度 provider trait 集合、URL 平台探测、跨平台适配器契约与 toon 输出。Core library: provider traits, URL-based platform detection, cross-platform adapter contracts & toon output.
Documentation

gitflow-core

Crates.io Documentation License: MIT

Core domain types, traits, and business logic for the gf workspace.

Overview

gitflow-core provides the foundational types and abstractions used across the gf ecosystem. This crate is designed to be platform-agnostic, defining the core interfaces that platform-specific implementations (GitHub, GitLab, GitCode) must implement.

Features

  • Domain Types: Issue, PR, Release, Review, Pipeline, Label, and more
  • Platform Abstractions: Traits for cross-platform Git hosting services
  • Error Handling: Consistent error types with thiserror
  • Output Formatting: CLI output utilities with miette integration
  • Auth Checking: Authentication status verification utilities
  • Type Safety: Strongly typed enums and newtypes for domain concepts

Installation

Add to your Cargo.toml:

[dependencies]
gitflow-core = "0.8"

Usage

Domain Types

use gf_core::{Issue, IssueState, IssueProvider};

// Work with issues
let issue = Issue {
    number: 42,
    title: "Fix bug".to_string(),
    state: IssueState::Open,
    // ...
};

Platform Traits

use gf_core::{IssueProvider, PrProvider, ReleaseProvider};

// Implement platform-specific providers
struct MyPlatform;

impl IssueProvider for MyPlatform {
    // Implement issue operations
}

impl PrProvider for MyPlatform {
    // Implement PR operations
}

Error Handling

use gf_core::Error;

fn do_something() -> Result<(), Error> {
    // Use the core error type
    Ok(())
}

Output Formatting

use gf_core::{CliOutput, CliError};

// Format CLI output
let output = CliOutput::success("Operation completed");
println!("{}", output);

// Handle errors
let error = CliError::new("Something went wrong");
eprintln!("{}", error);

Core Modules

issue

Issue tracking types and operations:

  • Issue - Issue data structure
  • IssueState - Open/Closed state
  • IssueProvider - Provider trait for issue operations

pr

Pull request types and operations:

  • PullRequest - PR data structure
  • PrState - Open/Closed/Merged state
  • PrProvider - Provider trait for PR operations

release

Release management types:

  • Release - Release data structure
  • ReleaseProvider - Provider trait for release operations

review

Code review types:

  • Review - Review data structure
  • ReviewProvider - Provider trait for review operations

pipeline

CI/CD pipeline types:

  • Pipeline - Pipeline data structure
  • PipelineStatus - Success/Failure/Running status
  • PipelineProvider - Provider trait for pipeline operations

platform

URL-based platform detection (not a capability trait — see the provider traits above for the actual per-platform abstraction):

  • Platform - Platform enum (GitHub/GitLab/GitCode)
  • PlatformDetection - detection result, with Platform::detect_from_remote_url()

auth

Authentication types and checking:

  • AuthChecker - Authentication status verification
  • AuthCheckResult - Auth check results

Design Principles

  1. Platform Agnostic: Core types work across all supported platforms
  2. Type Safety: Use enums and newtypes to prevent invalid states
  3. Error Handling: Consistent error types with context
  4. No I/O: Pure domain logic without network or file I/O
  5. Serializable: All types support serde for JSON/YAML/TOML

Ecosystem

This crate is part of the gf workspace:

Documentation

Contributing

Contributions are welcome! Please see the main repository for contribution guidelines.

License

Licensed under the MIT License. See LICENSE for details.