use tracing::instrument;
use crate::auth::TokenProvider;
use crate::error::AptuError;
use crate::github::auth::create_client_from_provider;
#[instrument(skip(provider), fields(owner = %owner, repo = %repo, head = %head_branch, base = %base_branch))]
#[allow(clippy::too_many_arguments)]
pub async fn create_pr(
provider: &dyn TokenProvider,
owner: &str,
repo: &str,
title: &str,
base_branch: &str,
head_branch: &str,
body: Option<&str>,
draft: bool,
) -> crate::Result<crate::github::pulls::PrCreateResult> {
let client = create_client_from_provider(provider)?;
crate::github::pulls::create_pull_request(
&client,
owner,
repo,
title,
head_branch,
base_branch,
body,
draft,
)
.await
.map_err(|e| AptuError::GitHub {
message: e.to_string(),
})
}