pub struct GitHub { /* private fields */ }Implementations§
Source§impl GitHub
impl GitHub
Sourcepub fn from_env() -> Result<Option<Self>, Error>
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)。
pub fn new( api: impl Into<String>, repo: impl Into<String>, token: String, ) -> Result<Self, Error>
pub fn repo(&self) -> &str
Sourcepub fn labeled(&self, label: &str) -> Result<Vec<Issue>, Error>
pub fn labeled(&self, label: &str) -> Result<Vec<Issue>, Error>
带 label 的未关闭 issue 与 PR(至多 100 件)。
Sourcepub fn comment(
&self,
number: u64,
body: &str,
op: &str,
) -> Result<String, Error>
pub fn comment( &self, number: u64, body: &str, op: &str, ) -> Result<String, Error>
在 issue / PR 下发评论,返回评论网址。过长的正文截断。正文末尾带幂等键 op 的
隐藏标记;已有带同一标记的评论(上次发出而未及记账)则不再发,返回其网址。
Sourcepub fn draft_pull_request(
&self,
branch: &str,
title: &str,
body: &str,
message: &str,
files: &[FileChange],
op: &str,
) -> Result<String, Error>
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§
impl !RefUnwindSafe for GitHub
impl !UnwindSafe for GitHub
impl Freeze for GitHub
impl Send for GitHub
impl Sync for GitHub
impl Unpin for GitHub
impl UnsafeUnpin for GitHub
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
Mutably borrows from an owned value. Read more