diff options
author | Cyborus <cyborus@noreply.codeberg.org> | 2024-06-10 19:30:52 +0200 |
---|---|---|
committer | Cyborus <cyborus@noreply.codeberg.org> | 2024-06-10 19:30:52 +0200 |
commit | 7a2d622152c1b496f8b16c8766880dc2a46c2375 (patch) | |
tree | a1d138fa2f3346983b394f0b08f0baee798309a1 | |
parent | Merge pull request 'fix warnings' (#76) from warnings into main (diff) | |
parent | add more success messages (diff) | |
download | forgejo-cli-7a2d622152c1b496f8b16c8766880dc2a46c2375.tar.xz forgejo-cli-7a2d622152c1b496f8b16c8766880dc2a46c2375.zip |
Merge pull request 'add more success messages' (#78) from success-msg into main
Reviewed-on: https://codeberg.org/Cyborus/forgejo-cli/pulls/78
-rw-r--r-- | src/issues.rs | 10 | ||||
-rw-r--r-- | src/prs.rs | 11 | ||||
-rw-r--r-- | src/release.rs | 25 |
3 files changed, 38 insertions, 8 deletions
diff --git a/src/issues.rs b/src/issues.rs index c2fbac7..d9667d4 100644 --- a/src/issues.rs +++ b/src/issues.rs @@ -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(()) } @@ -780,6 +780,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(()) } diff --git a/src/release.rs b/src/release.rs index 1745a5e..4fd85ed 100644 --- a/src/release.rs +++ b/src/release.rs @@ -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(()) } |