2 Commits

Author SHA1 Message Date
135acf09b7 Basic impl Display for the Release struct
I'm not certain what info I want to present when listing the Releases.

The idea is that the release version is the most important, and that it
matches the git-tag associated with the release. I'll print that first.

Next, the name of the release followed by the body text. The list of
releases will become quite large for some projects, and the body text
may include a changelog. Both of these will cause the output to become
quite large. I will need to create a size limiter, but I'm ignoring that
for now.

Who created the release and when may be useful when searching for a
release, so I've included that as the final section.
2025-07-02 12:56:17 -05:00
136c051c82 Fix: incorrect field names for Attachment
All checks were successful
/ Compile and upload a release build (release) Successful in 37s
I think I got the names from the Go source code, but the API emits JSON
that has these names instead. The api/swagger guide even says as much.

This caused the super fun quirk that the upload actually succeedes, but
the program reports an error condition because of the deserialization
failure. Time to bump a minor revision!
2025-06-12 17:21:48 -05:00
3 changed files with 30 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ async fn main() -> Result<(), gt_tool::Error> {
let releases =
gt_tool::api::release::list_releases(&client, &args.gitea_url, &args.repo).await?;
for release in releases {
println!("{:?}", release);
println!("{}", release);
}
}
gt_tool::cli::Commands::CreateRelease {

View File

@@ -9,7 +9,7 @@ pub struct Attachment {
name: String,
size: i64,
download_count: i64,
created: String, // TODO: Date-time struct
created_at: String, // TODO: Date-time struct
uuid: String,
download_url: String,
browser_download_url: String,
}

View File

@@ -1,3 +1,5 @@
use std::fmt::Display;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
@@ -19,6 +21,31 @@ pub struct Release {
author: Author,
}
impl Display for Release {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let body = if self.body.len() > 0 {
&self.body
} else {
&String::from("(empty body)")
};
write!(f,
"Tag: {}
Name: {}
{}
Published: {} (created: {})
Author: {} ({})
",
self.tag_name,
self.name,
body,
self.published_at,
self.created_at,
self.author.login,
self.author.email,
)
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Author {
id: usize,