2020-05-30 16:24:04 +00:00
|
|
|
use crate::{gitea::*, *};
|
|
|
|
use anyhow::{anyhow, Result};
|
|
|
|
|
2020-05-30 18:50:21 +00:00
|
|
|
pub(crate) async fn run(common: Common, tag: String) -> Result<()> {
|
2020-05-30 16:24:04 +00:00
|
|
|
let cli = client(&common)?;
|
|
|
|
let release = get_release_by_tag(
|
|
|
|
&cli,
|
|
|
|
&common.server,
|
|
|
|
&common.owner,
|
|
|
|
&common.repo,
|
2020-05-30 18:50:21 +00:00
|
|
|
&tag,
|
2020-05-30 16:24:04 +00:00
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
let resp = cli
|
|
|
|
.delete(
|
|
|
|
format!(
|
|
|
|
"{}/api/v1/repos/{}/{}/releases/{}",
|
|
|
|
&common.server, &common.owner, &common.repo, release.id
|
|
|
|
)
|
|
|
|
.as_str(),
|
|
|
|
)
|
|
|
|
.send()
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
if resp.status() != http::StatusCode::from_u16(204)? {
|
|
|
|
Err(anyhow!("wanted 204, got {}", resp.status()))
|
|
|
|
} else {
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|