pub struct GitLabMrProvider<R: CommandRunner = RealCommandRunner> { /* private fields */ }Expand description
GitLab Merge Request 提供者,通过 glab CLI 操作。
命令执行通过 CommandRunner 抽象,生产环境默认使用
RealCommandRunner,测试可注入自定义 runner 以模拟成功或失败场景。
§Examples
use gitflow_gitlab::GitLabMrProvider;
let provider = GitLabMrProvider::new("gitlab-org/gitlab");Implementations§
Source§impl GitLabMrProvider<RealCommandRunner>
impl GitLabMrProvider<RealCommandRunner>
Source§impl<R: CommandRunner> GitLabMrProvider<R>
impl<R: CommandRunner> GitLabMrProvider<R>
Sourcepub fn with_runner(repo: impl Into<String>, runner: R) -> Self
pub fn with_runner(repo: impl Into<String>, runner: R) -> Self
使用自定义 CommandRunner 创建提供者。
主要用于测试,可注入模拟 runner 以控制 glab CLI 的输出。
repo 格式为 namespace/project。
Sourcepub fn with_runner_and_repo_target(
repo: impl Into<String>,
repo_target: impl Into<String>,
runner: R,
) -> Self
pub fn with_runner_and_repo_target( repo: impl Into<String>, repo_target: impl Into<String>, runner: R, ) -> Self
使用自定义 CommandRunner 并显式指定 --repo 目标创建提供者。
主要用于测试,验证 repo_target(如完整 remote URL)被正确传给 glab。
Trait Implementations§
Source§impl<R: Clone + CommandRunner> Clone for GitLabMrProvider<R>
impl<R: Clone + CommandRunner> Clone for GitLabMrProvider<R>
Source§impl<R: Debug + CommandRunner> Debug for GitLabMrProvider<R>
impl<R: Debug + CommandRunner> Debug for GitLabMrProvider<R>
Source§impl<R: CommandRunner + Clone + 'static> PrProvider for GitLabMrProvider<R>
impl<R: CommandRunner + Clone + 'static> PrProvider for GitLabMrProvider<R>
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,
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,
auto 为 true 时显式传 --auto-merge,由 GitLab 在 pipeline 通过后
自动合并,调用立即返回;此时 merged 为 false。
显式传参而非依赖 glab 的隐式默认,以免 glab 版本变更时行为漂移。
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,
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,
获取指定 MR 的统一差异格式(unified diff)文本。
调用 glab mr diff <iid> 获取平台原生的 formatted diff 输出。
§Errors
当 MR 不存在或 glab CLI 调用失败时返回错误。
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,
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,
获取指定 MR 的 patch 格式文本(含邮件头信息)。
调用 glab api projects/{encoded}/merge_requests/{iid}.patch 获取
包含 commit 元数据的 patch 格式输出,可用于 git am。
§Errors
当 MR 不存在或 glab CLI 调用失败时返回错误。
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,
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)。
调用 glab repo view --output json 并解析 default_branch 字段。
§Errors
当 glab CLI 调用失败或响应无法解析时返回错误。
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
Auto Trait Implementations§
impl<R> Freeze for GitLabMrProvider<R>where
R: Freeze,
impl<R> RefUnwindSafe for GitLabMrProvider<R>where
R: RefUnwindSafe,
impl<R> Send for GitLabMrProvider<R>
impl<R> Sync for GitLabMrProvider<R>
impl<R> Unpin for GitLabMrProvider<R>where
R: Unpin,
impl<R> UnsafeUnpin for GitLabMrProvider<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for GitLabMrProvider<R>where
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more