gitflow-gitcode 1.2.0

gf 的 GitCode 适配器,基于 gitcode CLI 提供 Issue/MR/Release/Review 等能力。GitCode adapter for gf via gitcode CLI.
Documentation

gitflow-gitcode

Crates.io Documentation License: MIT

GitCode platform implementation for gf — Issue, PR, Release, and Review providers via gc CLI.

Overview

gitflow-gitcode provides GitCode-specific implementations of the core platform traits defined in gitflow-core. It uses the gc CLI under the hood for all GitCode API interactions.

Features

  • Issue Provider: Create, list, view, and manage GitCode Issues
  • PR Provider: Create, review, and manage Pull Requests
  • Release Provider: Create and manage GitCode Releases
  • Review Provider: Submit and manage code reviews
  • Pipeline Provider: Monitor GitCode CI/CD pipelines
  • Authentication: Leverages gc auth for authentication
  • Async Support: Full async/await support with Tokio

Installation

Add to your Cargo.toml:

[dependencies]
gitflow-gitcode = "0.8"

Prerequisites

This crate requires the GitCode CLI (gc) to be installed and authenticated:

# Install gc CLI (if available)
# See: https://gitcode.com for installation instructions

# Authenticate
gc auth login

Usage

Creating a GitCode Provider

use gf_gitcode::GitCodeProvider;
use gf_core::IssueProvider;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let provider = GitCodeProvider::new()?;

    // List open issues
    let issues = provider.list_issues("owner/repo", "open").await?;
    for issue in issues {
        println!("#{}: {}", issue.number, issue.title);
    }

    Ok(())
}

Working with Issues

use gf_gitcode::GitCodeProvider;
use gf_core::{IssueProvider, IssueState};

let provider = GitCodeProvider::new()?;

// Create an issue
let issue = provider.create_issue(
    "owner/repo",
    "Bug report",
    "Description of the bug",
    &["bug", "priority:high"],
).await?;

// Update issue state
provider.update_issue_state(
    "owner/repo",
    issue.number,
    IssueState::Closed,
).await?;

Working with Pull Requests

use gf_gitcode::GitCodeProvider;
use gf_core::PrProvider;

let provider = GitCodeProvider::new()?;

// Create a PR
let pr = provider.create_pr(
    "owner/repo",
    "feature-branch",
    "main",
    "Add new feature",
    "Detailed description",
).await?;

// Merge PR
provider.merge_pr("owner/repo", pr.number).await?;

Architecture

┌─────────────────────────────────────┐
│     gitflow-core (traits)       │
│  IssueProvider, PrProvider, etc.    │
└──────────────────┬──────────────────┘
                   │ implements
                   ▼
┌─────────────────────────────────────┐
│   gitflow-gitcode (this crate)  │
│      GitCodeProvider                │
└──────────────────┬──────────────────┘
                   │ uses
                   ▼
┌─────────────────────────────────────┐
│         gc CLI (GitCode API)        │
└─────────────────────────────────────┘

Error Handling

All operations return Result<T, gf_core::Error>:

use gf_gitcode::GitCodeProvider;
use gf_core::Error;

let provider = GitCodeProvider::new()?;
match provider.list_issues("owner/repo", "open").await {
    Ok(issues) => { /* handle issues */ },
    Err(Error::NotFound) => { /* repo not found */ },
    Err(Error::Auth) => { /* authentication failed */ },
    Err(e) => { /* other error */ },
}

Environment Variables

  • GITCODE_TOKEN — GitCode authentication token (optional if gc auth login was used)
  • GITCODE_HOST — GitCode instance hostname (optional)

Ecosystem

This crate is part of the gf workspace:

  • gitflow-core — Core types and traits
  • gitflow-github — GitHub platform implementation
  • gitflow-gitlab — GitLab platform implementation
  • gitflow-gitcode (this crate) — GitCode platform implementation
  • gf — CLI application

Documentation

Contributing

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

License

Licensed under the MIT License. See LICENSE for details.