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>
impl<'octo> PullRequestHandler<'octo>
Sourcepub fn media_type(self, media_type: MediaType) -> Self
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?;
Sourcepub async fn is_merged(&self, pr: u64) -> Result<bool>
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?;
Sourcepub async fn update_branch(&self, pr: u64) -> Result<bool>
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?;
Sourcepub async fn get(&self, pr: u64) -> Result<PullRequest>
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?;
Sourcepub async fn get_diff(&self, pr: u64) -> Result<String>
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?;
Sourcepub async fn get_patch(&self, pr: u64) -> Result<String>
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?;
Sourcepub fn create(
&self,
title: impl Into<String>,
head: impl Into<String>,
base: impl Into<String>,
) -> CreatePullRequestBuilder<'octo, '_>
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?;
Sourcepub fn update(&self, pull_number: u64) -> UpdatePullRequestBuilder<'octo, '_>
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?;
Sourcepub fn list(&self) -> ListPullRequestsBuilder<'_, '_>
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?;
Sourcepub fn list_reviews(&self, pr_number: u64) -> ListReviewsBuilder<'_, '_>
pub fn list_reviews(&self, pr_number: u64) -> ListReviewsBuilder<'_, '_>
Lists all of the Review
s associated with the pull request.
let reviews = octocrab::instance()
.pulls("owner", "repo")
.list_reviews(21u64.into())
.per_page(100)
.page(2u32)
.send()
.await?;
Sourcepub async fn request_reviews(
&self,
pr: u64,
reviewers: impl Into<Vec<String>>,
team_reviewers: impl Into<Vec<String>>,
) -> Result<Review>
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?;
Sourcepub async fn remove_requested_reviewers(
&self,
pr: u64,
reviewers: impl Into<Vec<String>>,
team_reviewers: impl Into<Vec<String>>,
) -> Result<Review>
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?;
Sourcepub async fn list_files(&self, pr: u64) -> Result<Page<DiffEntry>>
pub async fn list_files(&self, pr: u64) -> Result<Page<DiffEntry>>
List all DiffEntry
s associated with the pull request.
let files = octocrab::instance().pulls("owner", "repo").list_files(101).await?;
Sourcepub fn list_comments(&self, pr: Option<u64>) -> ListCommentsBuilder<'_, '_>
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?;
Sourcepub fn comment(&self, comment_id: CommentId) -> CommentBuilder<'_, '_>
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
}
Sourcepub 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
pub fn pull_number(&self, pull_nr: u64) -> SpecificPullRequestBuilder<'_, '_>
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
pub fn pr_review_actions( &self, pull_nr: u64, review_id: u64, ) -> SpecificReviewBuilder<'octo, '_>
Sourcepub fn pr_commits(
&self,
pr_number: u64,
) -> SpecificPullRequestCommitBuilder<'_, '_>
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?;
Sourcepub async fn reply_to_comment(
&self,
pull_nr: u64,
comment_id: CommentId,
comment: impl Into<String>,
) -> Result<ReviewComment>
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?;
Sourcepub fn merge(&self, pr: u64) -> MergePullRequestsBuilder<'_, '_>
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> 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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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