pub struct PullRequestHandler<'octo> { /* private fields */ }
Expand description

A client to GitHub’s pull request API.

Created with Octocrab::pulls.

Implementations§

source§

impl<'octo> PullRequestHandler<'octo>

source

pub fn media_type(self, media_type: MediaType) -> Self

Set the media type for this request.

let pr = octocrab::instance()
    .pulls("owner", "repo")
    .media_type(octocrab::params::pulls::MediaType::Full)
    .get(404)
    .await?;
source

pub async fn is_merged(&self, pr: u64) -> Result<bool>

Checks if a given pull request has been merged.

octocrab.pulls("owner", "repo").is_merged(101).await?;
source

pub async fn update_branch(&self, pr: u64) -> Result<bool>

Update the branch of a pull request.

octocrab.pulls("owner", "repo").update_branch(101).await?;
source

pub async fn get(&self, pr: u64) -> Result<PullRequest>

Get’s a given pull request with by its pr number.

let pr = octocrab::instance().pulls("owner", "repo").get(101).await?;
source

pub async fn get_diff(&self, pr: u64) -> Result<String>

Get’s a given pull request’s diff.

let diff = octocrab::instance().pulls("owner", "repo").get_diff(101).await?;
source

pub async fn get_patch(&self, pr: u64) -> Result<String>

Get’s a given pull request’s patch.

let diff = octocrab::instance().pulls("owner", "repo").get_patch(101).await?;
source

pub fn create( &self, title: impl Into<String>, head: impl Into<String>, base: impl Into<String> ) -> CreatePullRequestBuilder<'octo, '_>

Create a new pull request.

  • title — The title of the new pull request.
  • head — The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace head with a user like this: username:branch.
  • base — The name of the branch you want the changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repository that requests a merge to a base of another repository.
let pr = octocrab
    .pulls("owner", "repo")
    .create("title", "head", "base")
    .body("hello world!")
    .send()
    .await?;
source

pub fn update(&self, pull_number: u64) -> UpdatePullRequestBuilder<'octo, '_>

Update a new pull request.

  • pull_number — pull request number.
let pr = octocrab
    .pulls("owner", "repo")
    .update(1)
    .body("hello world!")
    .send()
    .await?;
source

pub fn list(&self) -> ListPullRequestsBuilder<'_, '_>

Creates a new ListPullRequestsBuilder that can be configured to filter listing pulling requests.

use octocrab::params;

let page = octocrab.pulls("owner", "repo").list()
    // Optional Parameters
    .state(params::State::Open)
    .head("master")
    .base("branch")
    .sort(params::pulls::Sort::Popularity)
    .direction(params::Direction::Ascending)
    .per_page(100)
    .page(5u32)
    // Send the request
    .send()
    .await?;
source

pub fn list_reviews(&self, pr_number: u64) -> ListReviewsBuilder<'_, '_>

Lists all of the Reviews associated with the pull request.

let reviews = octocrab::instance()
    .pulls("owner", "repo")
    .list_reviews(21u64.into())
    .per_page(100)
    .page(2u32)
    .send()
    .await?;
source

pub async fn request_reviews( &self, pr: u64, reviewers: impl Into<Vec<String>>, team_reviewers: impl Into<Vec<String>> ) -> Result<Review>

Request a review from users or teams.

let review = octocrab::instance().pulls("owner", "repo")
   .request_reviews(101, ["user1".to_string(), "user2".to_string()], ["team1".to_string(), "team2".to_string()])
 .await?;
source

pub async fn remove_requested_reviewers( &self, pr: u64, reviewers: impl Into<Vec<String>>, team_reviewers: impl Into<Vec<String>> ) -> Result<Review>

Remove a requested reviewer from users or teams.

let review = octocrab::instance().pulls("owner", "repo")
   .remove_requested_reviewers(101, ["user1".to_string(), "user2".to_string()], ["team1".to_string(), "team2".to_string()])
 .await?;
source

pub async fn list_files(&self, pr: u64) -> Result<Page<DiffEntry>>

List all DiffEntrys associated with the pull request.

let files = octocrab::instance().pulls("owner", "repo").list_files(101).await?;
source

pub fn list_comments(&self, pr: Option<u64>) -> ListCommentsBuilder<'_, '_>

Creates a new ListCommentsBuilder that can be configured to list and filter Comments for a particular pull request. If no pull request is specified, lists comments for the whole repo.

use octocrab::params;

let page = octocrab.pulls("owner", "repo").list_comments(Some(5))
    // Optional Parameters
    .sort(params::pulls::comments::Sort::Created)
    .direction(params::Direction::Ascending)
    .per_page(100)
    .page(5u32)
    .since(chrono::Utc::now() - chrono::Duration::days(1))
    // Send the request
    .send()
    .await?;
source

pub fn merge(&self, pr: u64) -> MergePullRequestsBuilder<'_, '_>

Creates a new MergePullRequestsBuilder that can be configured used to merge a pull request.

use octocrab::params;

let page = octocrab.pulls("owner", "repo").merge(20)
    // Optional Parameters
    .title("cool title")
    .message("a message")
    // Won't merge of the HEAD commit of the PR branch is not the same
    .sha("0123456")
    // The method to use when merging, will default to `Merge`
    .method(params::pulls::MergeMethod::Squash)
    // Send the request
    .send()
    .await?;

Auto Trait Implementations§

§

impl<'octo> Freeze for PullRequestHandler<'octo>

§

impl<'octo> !RefUnwindSafe for PullRequestHandler<'octo>

§

impl<'octo> Send for PullRequestHandler<'octo>

§

impl<'octo> Sync for PullRequestHandler<'octo>

§

impl<'octo> Unpin for PullRequestHandler<'octo>

§

impl<'octo> !UnwindSafe for PullRequestHandler<'octo>

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more