Skip to main content

GitHub

Struct GitHub 

Source
pub struct GitHub { /* private fields */ }

Implementations§

Source§

impl GitHub

Source

pub fn from_env() -> Result<Option<Self>, Error>

ZIYUAN_GITHUB_REPO(owner/repo)未设时为 Ok(None)。令牌取 ZIYUAN_GITHUB_TOKEN, 否则 GITHUB_TOKEN;ZIYUAN_GITHUB_API 可改 API 地址(GitHub Enterprise)。

Source

pub fn new( api: impl Into<String>, repo: impl Into<String>, token: String, ) -> Result<Self, Error>

Source

pub fn repo(&self) -> &str

Source

pub fn labeled(&self, label: &str) -> Result<Vec<Issue>, Error>

带 label 的未关闭 issue 与 PR(至多 100 件)。

Source

pub fn comments(&self, number: u64) -> Result<Vec<Comment>, Error>

issue / PR 下的评论(至多 100 条)。

Source

pub fn comment( &self, number: u64, body: &str, op: &str, ) -> Result<String, Error>

在 issue / PR 下发评论,返回评论网址。过长的正文截断。正文末尾带幂等键 op 的 隐藏标记;已有带同一标记的评论(上次发出而未及记账)则不再发,返回其网址。

Source

pub fn draft_pull_request( &self, branch: &str, title: &str, body: &str, message: &str, files: &[FileChange], op: &str, ) -> Result<String, Error>

以默认分支最新提交为底,在远端新建分支 branch、一次提交写入 files 的 after, 再开草稿 PR,返回 PR 网址。先核对每个文件的远端原文与 before 一致(新建的须不存在), 不一致则不开,以免 PR 悄悄冲掉远端的改动。 message 为 PR 里那个提交的说明(与本地提交的相同,便于对应),末尾另加 Ziyuan-Op 尾注。

按幂等键 op 续作:branch 上已有正文带同一标记的 PR 就返回它;分支已由同一 op 建好 (提交带同一尾注)而 PR 未开,就只开 PR。分支或 PR 已存在却不是这次驿传所建,则报错、不覆盖。

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.