pub struct GitHub<R: ProcessRunner = JobRunner> { /* private fields */ }Expand description
The real GitHub client. Generic over the ProcessRunner so tests can
inject a fake process executor; GitHub::new() uses the real job-backed
runner.
Implementations§
Source§impl<R: ProcessRunner> GitHub<R>
impl<R: ProcessRunner> GitHub<R>
Sourcepub fn with_runner(runner: R) -> Self
pub fn with_runner(runner: R) -> Self
Create a client driving runner — inject a fake in tests.
Sourcepub fn default_timeout(self, timeout: Duration) -> Self
pub fn default_timeout(self, timeout: Duration) -> Self
Apply a default timeout to every command this client builds.
Sourcepub fn default_env(
self,
key: impl AsRef<OsStr>,
value: impl AsRef<OsStr>,
) -> Self
pub fn default_env( self, key: impl AsRef<OsStr>, value: impl AsRef<OsStr>, ) -> Self
Set an environment variable on every command this client builds
(e.g. GIT_TERMINAL_PROMPT=0).
Sourcepub fn default_env_remove(self, key: impl AsRef<OsStr>) -> Self
pub fn default_env_remove(self, key: impl AsRef<OsStr>) -> Self
Remove an inherited environment variable on every command this client builds.
Source§impl<R: ProcessRunner> GitHub<R>
impl<R: ProcessRunner> GitHub<R>
Sourcepub async fn run_args(&self, args: &[&str]) -> Result<String>
pub async fn run_args(&self, args: &[&str]) -> Result<String>
Run gh <args> over string slices — gh.run_args(&["pr", "list"])
without allocating a Vec<String>. Inherent (not on the object-safe
trait), so it can take &[&str]; forwards to the same path as
GitHubApi::run.
Sourcepub async fn run_raw_args(&self, args: &[&str]) -> Result<ProcessResult<String>>
pub async fn run_raw_args(&self, args: &[&str]) -> Result<ProcessResult<String>>
Like run_args but never errors on a non-zero exit
(mirrors GitHubApi::run_raw).
Trait Implementations§
Source§impl<R: ProcessRunner> GitHubApi for GitHub<R>
impl<R: ProcessRunner> GitHubApi for GitHub<R>
Source§fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Run
gh <args>, returning trimmed stdout (throws on a non-zero exit).Source§fn run_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<ProcessResult<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn run_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
args: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<ProcessResult<String>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Like
GitHubApi::run but never errors on a non-zero exit — returns the
captured ProcessResult.Source§fn version<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn version<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Installed GitHub CLI version (
gh --version).Source§fn auth_status<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn auth_status<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Whether the user is authenticated (
gh auth status exits zero).Source§fn repo_view<'life0, 'life1, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Repo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn repo_view<'life0, 'life1, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Repo>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
The repository for
dir (gh repo view --json …).Source§fn pr_list<'life0, 'life1, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<PullRequest>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn pr_list<'life0, 'life1, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<PullRequest>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Pull requests for
dir (gh pr list --json …).Source§fn pr_list_for_branch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
head: &'life2 str,
base: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<PullRequest>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn pr_list_for_branch<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
head: &'life2 str,
base: &'life3 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<PullRequest>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Pull requests that merge
head into base, in any state — open, closed,
or merged (gh pr list --head <head> --base <base> --state all --json …).
Each carries its title, URL, and state. Empty when none match.Source§fn pr_view<'life0, 'life1, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
number: u64,
) -> Pin<Box<dyn Future<Output = Result<PullRequest>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn pr_view<'life0, 'life1, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
number: u64,
) -> Pin<Box<dyn Future<Output = Result<PullRequest>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
A single pull request by number (
gh pr view <n> --json …).Source§fn issue_list<'life0, 'life1, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<Issue>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn issue_list<'life0, 'life1, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<Vec<Issue>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Issues for
dir (gh issue list --json …).Source§fn pr_create<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
title: &'life2 str,
body: &'life3 str,
head: Option<String>,
base: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn pr_create<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
dir: &'life1 Path,
title: &'life2 str,
body: &'life3 str,
head: Option<String>,
base: Option<String>,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Open a pull request, returning its URL (
gh pr create). head (the
source branch; None = the current branch) and base (the target;
None = the repo default) are owned Option<String>s to keep the trait
mockall-friendly.Auto Trait Implementations§
impl<R> Freeze for GitHub<R>where
R: Freeze,
impl<R> RefUnwindSafe for GitHub<R>where
R: RefUnwindSafe,
impl<R> Send for GitHub<R>
impl<R> Sync for GitHub<R>
impl<R> Unpin for GitHub<R>where
R: Unpin,
impl<R> UnsafeUnpin for GitHub<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for GitHub<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
Mutably borrows from an owned value. Read more