mirror of
https://codeberg.org/Cyborus/forgejo-cli.git
synced 2024-11-23 18:31:46 +01:00
add more success messages
This commit is contained in:
parent
d10b5172be
commit
56f0e8babf
3 changed files with 38 additions and 8 deletions
|
@ -574,8 +574,16 @@ pub async fn close_issue(
|
|||
unset_due_date: None,
|
||||
updated_at: None,
|
||||
};
|
||||
api.issue_edit_issue(repo.owner(), repo.name(), issue, edit)
|
||||
let issue_data = api
|
||||
.issue_edit_issue(repo.owner(), repo.name(), issue, edit)
|
||||
.await?;
|
||||
|
||||
let issue_title = issue_data
|
||||
.title
|
||||
.as_deref()
|
||||
.ok_or_eyre("issue does not have title")?;
|
||||
|
||||
println!("Closed issue {issue}: \"{issue_title}\"");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
11
src/prs.rs
11
src/prs.rs
|
@ -781,6 +781,17 @@ async fn merge_pr(
|
|||
let pr_number = pr_info.number.ok_or_eyre("pr does not have number")?;
|
||||
api.repo_merge_pull_request(repo.owner(), repo.name(), pr_number, request)
|
||||
.await?;
|
||||
|
||||
let pr_title = pr_info
|
||||
.title
|
||||
.as_deref()
|
||||
.ok_or_eyre("pr does not have title")?;
|
||||
let pr_base = pr_info.base.as_ref().ok_or_eyre("pr does not have base")?;
|
||||
let base_label = pr_base
|
||||
.label
|
||||
.as_ref()
|
||||
.ok_or_eyre("base does not have label")?;
|
||||
println!("Merged PR #{pr_number} \"{pr_title}\" into `{base_label}`");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ async fn create_release(
|
|||
let release_opt = forgejo_api::structs::CreateReleaseOption {
|
||||
body,
|
||||
draft: Some(draft),
|
||||
name: Some(name),
|
||||
name: Some(name.clone()),
|
||||
prerelease: Some(prerelease),
|
||||
tag_name,
|
||||
target_commitish: None,
|
||||
|
@ -259,6 +259,8 @@ async fn create_release(
|
|||
.await?;
|
||||
}
|
||||
|
||||
println!("Created release {name}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -461,23 +463,25 @@ async fn create_asset(
|
|||
)
|
||||
.await?;
|
||||
|
||||
println!("Added attachment `{}` to {}", asset, release);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn delete_asset(
|
||||
repo: &RepoName,
|
||||
api: &Forgejo,
|
||||
release: String,
|
||||
asset: String,
|
||||
release_name: String,
|
||||
asset_name: String,
|
||||
) -> eyre::Result<()> {
|
||||
let release = find_release(repo, api, &release).await?;
|
||||
let release = find_release(repo, api, &release_name).await?;
|
||||
let assets = release
|
||||
.assets
|
||||
.as_ref()
|
||||
.ok_or_else(|| eyre::eyre!("release does not have assets"))?;
|
||||
let asset = assets
|
||||
.iter()
|
||||
.find(|a| a.name.as_ref() == Some(&asset))
|
||||
.find(|a| a.name.as_ref() == Some(&asset_name))
|
||||
.ok_or_else(|| eyre!("asset not found"))?;
|
||||
let release_id = release
|
||||
.id
|
||||
|
@ -487,6 +491,7 @@ async fn delete_asset(
|
|||
.ok_or_else(|| eyre::eyre!("asset does not have id"))?;
|
||||
api.repo_delete_release_attachment(repo.owner(), repo.name(), release_id, asset_id)
|
||||
.await?;
|
||||
println!("Removed attachment `{}` from {}", asset_name, release_name);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -535,17 +540,23 @@ async fn download_asset(
|
|||
.to_vec()
|
||||
}
|
||||
};
|
||||
let output = output
|
||||
let real_output = output
|
||||
.as_deref()
|
||||
.unwrap_or_else(|| std::path::Path::new(&asset));
|
||||
tokio::fs::OpenOptions::new()
|
||||
.create_new(true)
|
||||
.write(true)
|
||||
.open(output)
|
||||
.open(real_output)
|
||||
.await?
|
||||
.write_all(file.as_ref())
|
||||
.await?;
|
||||
|
||||
if output.is_some() {
|
||||
println!("Downloaded {asset} into {}", real_output.display());
|
||||
} else {
|
||||
println!("Downloaded {asset}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue