aptu_core/facade/
pr_create.rs1#[cfg(not(target_arch = "wasm32"))]
6use tracing::instrument;
7
8#[cfg(not(target_arch = "wasm32"))]
9use crate::auth::TokenProvider;
10use crate::error::AptuError;
11#[cfg(not(target_arch = "wasm32"))]
12use crate::github::auth::create_client_from_provider;
13
14#[cfg(not(target_arch = "wasm32"))]
37#[instrument(skip(provider), fields(owner = %owner, repo = %repo, head = %head_branch, base = %base_branch))]
38#[allow(clippy::too_many_arguments)]
39pub async fn create_pr(
40 provider: &dyn TokenProvider,
41 owner: &str,
42 repo: &str,
43 title: &str,
44 base_branch: &str,
45 head_branch: &str,
46 body: Option<&str>,
47 draft: bool,
48) -> crate::Result<crate::github::pulls::PrCreateResult> {
49 let client = create_client_from_provider(provider)?;
51
52 crate::github::pulls::create_pull_request(
54 &client,
55 owner,
56 repo,
57 title,
58 head_branch,
59 base_branch,
60 body,
61 draft,
62 )
63 .await
64 .map_err(|e| AptuError::GitHub {
65 message: e.to_string(),
66 })
67}
68
69#[cfg(target_arch = "wasm32")]
70pub async fn create_pr(
71 _provider: &dyn crate::auth::TokenProvider,
72 _owner: &str,
73 _repo: &str,
74 _title: &str,
75 _base_branch: &str,
76 _head_branch: &str,
77 _body: Option<&str>,
78 _draft: bool,
79) -> crate::Result<crate::github::pulls::PrCreateResult> {
80 crate::facade::wasm_unsupported!("create_pr");
81}