Skip to main content

PrProvider

Trait PrProvider 

Source
pub trait PrProvider:
    Debug
    + Send
    + Sync {
Show 14 methods // Required methods fn create<'life0, 'async_trait>( &'life0 self, args: CreatePrArgs, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn list<'life0, 'async_trait>( &'life0 self, args: ListPrArgs, ) -> Pin<Box<dyn Future<Output = Result<Paged<PrData>>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn view<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn close<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn reopen<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn comment<'life0, 'life1, 'async_trait>( &'life0 self, number: u64, body: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<CommentData>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; fn merge<'life0, 'async_trait>( &'life0 self, number: u64, strategy: Option<MergeStrategy>, auto: bool, ) -> Pin<Box<dyn Future<Output = Result<MergeResult>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn checkout<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn mark_ready<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn mark_wip<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn sync_branch<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn diff<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn patch<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; fn default_branch<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait;
}
Expand description

PR 操作的平台抽象。

所有平台实现(GitHub/GitLab/GitCode)都必须实现此 trait, 以提供统一的 PR 创建、列表、查看、关闭、合并、检出等能力。

§Errors

所有方法在平台调用失败、反序列化失败或鉴权失败时返回 CoreError。

Required Methods§

Source

fn create<'life0, 'async_trait>( &'life0 self, args: CreatePrArgs, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

创建一条新 PR,返回平台生成的完整数据。

§Errors

当平台 API 调用失败或参数非法时返回错误。

Source

fn list<'life0, 'async_trait>( &'life0 self, args: ListPrArgs, ) -> Pin<Box<dyn Future<Output = Result<Paged<PrData>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

根据过滤条件列出 PR 列表。

返回的 Paged 携带截断标志,语义见 crate::paging。

§Errors

当平台 API 调用失败或过滤条件非法时返回错误。

Source

fn view<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

查看指定编号的 PR 详情。

§Errors

当 PR 不存在或平台 API 调用失败时返回错误。

Source

fn close<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

关闭指定编号的 PR,返回更新后的数据。

§Errors

当 PR 不存在或平台 API 调用失败时返回错误。

Source

fn reopen<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

重新打开指定编号的 PR,返回更新后的数据。

§Errors

当 PR 不存在或平台 API 调用失败时返回错误。

Source

fn comment<'life0, 'life1, 'async_trait>( &'life0 self, number: u64, body: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<CommentData>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

在指定 PR 上添加评论,返回新建评论的数据。

§Errors

当 PR 不存在、body 为空或平台 API 调用失败时返回错误。

Source

fn merge<'life0, 'async_trait>( &'life0 self, number: u64, strategy: Option<MergeStrategy>, auto: bool, ) -> Pin<Box<dyn Future<Output = Result<MergeResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

合并指定编号的 PR,返回合并结果。

strategy 指定合并策略(merge/squash/rebase)。 未指定时使用平台默认策略。

auto 为 true 时排队合并:满足条件即由平台自动完成合并, 调用方不必等待 CI。GitHub 与 GitLab 原生支持;GitCode 不支持, 传 true 会返回 [CoreError::Platform](与 PipelineProvider 的处理一致)。

§Errors

当 PR 不存在、无法合并、平台不支持 auto 或平台 API 调用失败时返回错误。

Source

fn checkout<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

在本地检出指定 PR 的分支。

§Errors

当 PR 不存在或 git 操作失败时返回错误。

Source

fn mark_ready<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

将草稿 PR 标记为可审查状态(ready for review)。

§Errors

当 PR 不存在、不是草稿或平台 API 调用失败时返回错误。

Source

fn mark_wip<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<PrData>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

将 PR 标记为草稿状态(work in progress)。

§Errors

当 PR 不存在或平台 API 调用失败时返回错误。

Source

fn sync_branch<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

同步 PR 分支(将 base 分支的最新变更合入 head 分支)。

§Errors

当 PR 不存在或同步失败时返回错误。

Source

fn diff<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

获取指定 PR 的统一差异格式(unified diff)文本。

返回平台原生的 unified diff 输出,可直接用于 git apply。

§Errors

当 PR 不存在或平台 API 调用失败时返回 CoreError。

Source

fn patch<'life0, 'async_trait>( &'life0 self, number: u64, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

获取指定 PR 的 patch 格式文本(含邮件头信息)。

返回包含 commit 元数据的 patch 格式输出,可用于 git am。

§Errors

当 PR 不存在或平台 API 调用失败时返回 CoreError。

Source

fn default_branch<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

查询仓库配置的默认分支(如 main、dev)。

用于 pr create 在未显式指定 --base 时探测目标分支,避免硬编码 "main" 导致默认分支非 main 的仓库创建出目标错误的 PR/MR。

§Errors

当平台 API 调用失败或平台不支持该查询(如 GitCode)时返回错误。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§