Struct PullRequestHandler

Source
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 comment(&self, comment_id: CommentId) -> CommentBuilder<'_, '_>

creates a new CommentBuilder for GET/PATCH/DELETE requests to the /repos/{owner}/{repo}/pulls/{pr}/comments/{comment_id} endpoint

 use octocrab::models::CommentId;
use octocrab::models::pulls::Comment;
 async fn run() -> octocrab::Result<Comment> {
    let octocrab = octocrab::Octocrab::default();
    let _ = octocrab.pulls("owner", "repo").comment(CommentId(21)).delete();
    let _ = octocrab.pulls("owner", "repo").comment(CommentId(42)).update("new comment");
    let comment = octocrab.pulls("owner", "repo").comment(CommentId(42)).get().await;

    comment
 }
Source

pub fn pull_number(&self, pull_nr: u64) -> SpecificPullRequestBuilder<'_, '_>

👎Deprecated since 0.34.4: specific PR builder transitioned to pr_review_actions, pr_commits, reply_to_comment

creates a builder for the /repos/{owner}/{repo}/pulls/{pull_number}/...... endpoint working with particular pull request, e.g.

  • /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/events
  • /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}
  • /repos/{owner}/{repo}/pulls/{pull_number}/commits
  • /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments
  • /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/dismissals
  • /repos/{owner}/{repo}/pulls/{pull_number}/comments/{comment_id}/replies
Source

pub fn pr_review_actions( &self, pull_nr: u64, review_id: u64, ) -> SpecificReviewBuilder<'octo, '_>

Source

pub fn pr_commits( &self, pr_number: u64, ) -> SpecificPullRequestCommitBuilder<'_, '_>

Lists a maximum of 250 commits for a pull request.

To receive a complete commit list for pull requests with more than 250 commits, use the List commits endpoint.

let commits = octocrab::instance()
    .pulls("owner", "repo")
    .pr_commits(21u64)
    .per_page(100)
    .page(2u32)
    .send()
    .await?;
Source

pub async fn reply_to_comment( &self, pull_nr: u64, comment_id: CommentId, comment: impl Into<String>, ) -> Result<ReviewComment>

Creates a reply to a specific comment of a pull request specified in the first argument

 async fn run() -> octocrab::Result<()> {
use octocrab::params;

let page = octocrab.pulls("owner", "repo").reply_to_comment(142, CommentId(24), "This is my reply")
    .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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
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>,

Source§

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>,

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

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T