Update main.rs to use new attachment iface

This commit is contained in:
2025-06-07 23:57:19 -05:00
parent a5f6335b5f
commit 06795df3f7

View File

@@ -1,3 +1,5 @@
use std::fs;
use gt_tool::cli::Args; use gt_tool::cli::Args;
use gt_tool::structs::release::{CreateReleaseOption, Release}; use gt_tool::structs::release::{CreateReleaseOption, Release};
@@ -78,14 +80,26 @@ async fn main() -> Result<(), gt_tool::Error> {
gt_tool::api::release::list_releases(&client, &args.gitea_url, &args.repo).await?; gt_tool::api::release::list_releases(&client, &args.gitea_url, &args.repo).await?;
if let Some(release) = match_release_by_tag(&tag_name, release_candidates) { if let Some(release) = match_release_by_tag(&tag_name, release_candidates) {
gt_tool::api::release_attachment::create_release_attachment( for file in &files {
&client, match fs::exists(file) {
&args.gitea_url, Ok(true) => continue,
&args.repo, Ok(false) => return Err(gt_tool::Error::NoSuchFile),
release.id, Err(e) => {
files, eprintln!("Uh oh! The file-exists check couldn't be done: {e}");
) panic!("TODO: Deal with scenario where the file's existence cannot be checked (e.g.: no permission)");
.await?; },
}
}
for file in files {
let _attach_desc = gt_tool::api::release_attachment::create_release_attachment(
&client,
&args.gitea_url,
&args.repo,
release.id,
file,
)
.await?;
}
} else { } else {
println!("ERR: Couldn't find a release matching the tag \"{tag_name}\"."); println!("ERR: Couldn't find a release matching the tag \"{tag_name}\".");
return Err(gt_tool::Error::NoSuchRelease); return Err(gt_tool::Error::NoSuchRelease);