Struct octocrab::pulls::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>
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 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?;