merging a pr does not return a body
This commit is contained in:
parent
bc9dbc6348
commit
e732034aea
23
src/lib.rs
23
src/lib.rs
|
@ -118,6 +118,16 @@ impl Forgejo {
|
||||||
self.execute_str(request).await
|
self.execute_str(request).await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn post_unit<T: Serialize>(
|
||||||
|
&self,
|
||||||
|
path: &str,
|
||||||
|
body: &T,
|
||||||
|
) -> Result<(), ForgejoError> {
|
||||||
|
let url = self.url.join("api/v1/").unwrap().join(path).unwrap();
|
||||||
|
let request = self.client.post(url).json(body).build()?;
|
||||||
|
self.execute_unit(request).await
|
||||||
|
}
|
||||||
|
|
||||||
async fn post_raw(
|
async fn post_raw(
|
||||||
&self,
|
&self,
|
||||||
path: &str,
|
path: &str,
|
||||||
|
@ -179,6 +189,19 @@ impl Forgejo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Like `execute`, but returns unit.
|
||||||
|
async fn execute_unit(&self, request: Request) -> Result<(), ForgejoError> {
|
||||||
|
let response = self.client.execute(request).await?;
|
||||||
|
match response.status() {
|
||||||
|
status if status.is_success() => Ok(()),
|
||||||
|
status if status.is_client_error() => Err(ForgejoError::ApiError(
|
||||||
|
status,
|
||||||
|
response.json::<ErrorMessage>().await?.message.unwrap_or_else(|| String::from("[no message]")),
|
||||||
|
)),
|
||||||
|
status => Err(ForgejoError::UnexpectedStatusCode(status)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Like `execute`, but returns `Ok(None)` on 404.
|
/// Like `execute`, but returns `Ok(None)` on 404.
|
||||||
async fn execute_opt<T: DeserializeOwned>(
|
async fn execute_opt<T: DeserializeOwned>(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl Forgejo {
|
||||||
pr: u64,
|
pr: u64,
|
||||||
opts: MergePullRequestOption,
|
opts: MergePullRequestOption,
|
||||||
) -> Result<(), ForgejoError> {
|
) -> Result<(), ForgejoError> {
|
||||||
self.post(&format!("repos/{owner}/{repo}/pulls/{pr}/merge"), &opts)
|
self.post_unit(&format!("repos/{owner}/{repo}/pulls/{pr}/merge"), &opts)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue