tangled-api 0.1.0

Lexicon-generated XRPC client for Tangled and AT Protocol APIs
Documentation
// @generated by `cargo xtask codegen` — do not edit.
// source: lexicons/repo/mergeCheck.json (sh.tangled.repo.mergeCheck)

#![allow(clippy::all)]

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct ConflictInfo {
    /// Name of the conflicted file
    pub filename: String,
    /// Reason for the conflict
    pub reason: String,
    /// Unknown fields, preserved across read-modify-write round-trips.
    #[serde(flatten)]
    pub extra: serde_json::Map<String, serde_json::Value>,
}

pub const NSID: &str = "sh.tangled.repo.mergeCheck";

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Input {
    /// Target branch to merge into
    pub branch: String,
    /// DID of the repository owner
    pub did: String,
    /// Name of the repository
    pub name: String,
    /// Patch or pull request to check for merge conflicts
    pub patch: String,
}

#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
pub struct Output {
    /// List of files with merge conflicts
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub conflicts: Option<
        Vec<crate::lexicon::sh::tangled::repo::merge_check::ConflictInfo>,
    >,
    /// Error message if check failed
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub error: Option<String>,
    /// Whether the merge has conflicts
    pub is_conflicted: bool,
    /// Additional message about the merge check
    #[serde(skip_serializing_if = "Option::is_none", default)]
    pub message: Option<String>,
}

/// Check if a merge is possible between two branches
pub fn merge_check(
    http: &reqwest::Client,
    base: &str,
    input: &Input,
) -> reqwest::RequestBuilder {
    let rb = http.post(crate::xrpc::xrpc_url(base, NSID));
    let rb = rb.header(reqwest::header::ACCEPT, "application/json");
    let rb = rb.json(input);
    rb
}