Skip to content

Commit

Permalink
Add head repo to create pr (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
abrassel authored Jun 11, 2024
1 parent cb55393 commit 6331b24
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/api/pulls/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ pub struct CreatePullRequestBuilder<'octo, 'b> {
draft: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
maintainer_can_modify: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
head_repo: Option<String>,
}

impl<'octo, 'b> CreatePullRequestBuilder<'octo, 'b> {
Expand All @@ -30,6 +32,7 @@ impl<'octo, 'b> CreatePullRequestBuilder<'octo, 'b> {
body: None,
draft: None,
maintainer_can_modify: None,
head_repo: None,
}
}

Expand All @@ -51,6 +54,11 @@ impl<'octo, 'b> CreatePullRequestBuilder<'octo, 'b> {
self
}

pub fn head_repo(mut self, head_repo: impl Into<Option<String>>) -> Self {
self.head_repo = head_repo.into();
self
}

/// Sends the request to create the pull request.
pub async fn send(self) -> crate::Result<crate::models::pulls::PullRequest> {
let route = format!(
Expand All @@ -65,7 +73,6 @@ impl<'octo, 'b> CreatePullRequestBuilder<'octo, 'b> {

#[cfg(test)]
mod tests {

#[tokio::test]
async fn serialize() {
let octocrab = crate::Octocrab::default();
Expand All @@ -74,6 +81,7 @@ mod tests {
.create("test-pr", "master", "branch")
.body(String::from("testing..."))
.draft(true)
.head_repo(String::from("foobar"))
.maintainer_can_modify(true);

assert_eq!(
Expand All @@ -85,6 +93,7 @@ mod tests {
"body": "testing...",
"draft": true,
"maintainer_can_modify": true,
"head_repo": "foobar",
})
)
}
Expand Down

0 comments on commit 6331b24

Please sign in to comment.