Autoformat

This commit is contained in:
2025-07-03 17:30:56 -05:00
parent c9dda5760c
commit 84eaaa1dbd
5 changed files with 22 additions and 36 deletions

View File

@@ -1,9 +1,6 @@
use crate::{ use crate::{
Result, Result,
structs::{ structs::release::{CreateReleaseOption, Release},
release::{CreateReleaseOption, Release},
},
}; };
pub fn get_release(_id: u64) -> Result<Release> { pub fn get_release(_id: u64) -> Result<Release> {
@@ -59,7 +56,7 @@ pub async fn create_release(
return Ok(new_release); return Ok(new_release);
} else if response.status().is_client_error() { } else if response.status().is_client_error() {
let mesg = crate::decode_client_error(response).await?; let mesg = crate::decode_client_error(response).await?;
return Err(crate::Error::ApiErrorMessage(mesg)) return Err(crate::Error::ApiErrorMessage(mesg));
} }
panic!("Reached end of create_release without matching a return path"); panic!("Reached end of create_release without matching a return path");
} }

View File

@@ -22,8 +22,10 @@ pub async fn create_release_attachment(
Ok(false) => return Err(crate::Error::NoSuchFile), Ok(false) => return Err(crate::Error::NoSuchFile),
Err(e) => { Err(e) => {
eprintln!("Uh oh! The file-exists check couldn't be done: {e}"); 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)"); panic!(
}, "TODO: Deal with scenario where the file's existence cannot be checked (e.g.: no permission)"
);
}
} }
println!("Uploading file {}", &file); println!("Uploading file {}", &file);
@@ -44,7 +46,7 @@ pub async fn create_release_attachment(
let attachment_desc = response let attachment_desc = response
.json::<Attachment>() .json::<Attachment>()
.await .await
.map_err( crate::Error::from)?; .map_err(crate::Error::from)?;
return Ok(attachment_desc); return Ok(attachment_desc);
} else if response.status().is_client_error() { } else if response.status().is_client_error() {
let mesg = crate::decode_client_error(response).await?; let mesg = crate::decode_client_error(response).await?;

View File

@@ -10,13 +10,11 @@ pub struct ApiError {
url: String, url: String,
} }
pub (crate) async fn decode_client_error(response: reqwest::Response) -> Result<ApiError> { pub(crate) async fn decode_client_error(response: reqwest::Response) -> Result<ApiError> {
response response
.json::<ApiError>() .json::<ApiError>()
.await .await
.map_err(|reqwest_err| { .map_err(|reqwest_err| crate::Error::WrappedReqwestErr(reqwest_err))
crate::Error::WrappedReqwestErr(reqwest_err)
})
} }
#[derive(Debug)] #[derive(Debug)]

View File

@@ -1,4 +1,3 @@
use std::path; use std::path;
use gt_tool::cli::Args; use gt_tool::cli::Args;
@@ -22,10 +21,7 @@ async fn main() -> Result<(), gt_tool::Error> {
headers.append("Authorization", token.parse().unwrap()); headers.append("Authorization", token.parse().unwrap());
} }
let client = reqwest::Client::builder() let client = reqwest::Client::builder()
.user_agent(format!( .user_agent(format!("gt-tools-agent-{}", env!("CARGO_PKG_VERSION")))
"gt-tools-agent-{}",
env!("CARGO_PKG_VERSION")
))
.default_headers(headers) .default_headers(headers)
.build()?; .build()?;
@@ -37,14 +33,11 @@ async fn main() -> Result<(), gt_tool::Error> {
// user's command prompt. Otherwise the newest item scrolls off the // user's command prompt. Otherwise the newest item scrolls off the
// screen and can't be seen. // screen and can't be seen.
itertools::Itertools::intersperse( itertools::Itertools::intersperse(
releases releases.iter().rev().map(|release| release.colorized()),
.iter() String::from(""),
.rev() )
.map(|release| release.colorized()), .map(|release| println!("{}", release))
String::from("") .fold((), |_, _| ());
)
.map(|release| println!("{}", release))
.fold((), |_, _| () );
} }
gt_tool::cli::Commands::CreateRelease { gt_tool::cli::Commands::CreateRelease {
name, name,
@@ -61,13 +54,8 @@ async fn main() -> Result<(), gt_tool::Error> {
tag_name, tag_name,
target_commitish, target_commitish,
}; };
gt_tool::api::release::create_release( gt_tool::api::release::create_release(&client, &args.gitea_url, &args.repo, submission)
&client, .await?;
&args.gitea_url,
&args.repo,
submission,
)
.await?;
} }
gt_tool::cli::Commands::UploadRelease { gt_tool::cli::Commands::UploadRelease {
tag_name, tag_name,
@@ -97,8 +85,10 @@ async fn main() -> Result<(), gt_tool::Error> {
Ok(false) => return Err(gt_tool::Error::NoSuchFile), Ok(false) => return Err(gt_tool::Error::NoSuchFile),
Err(e) => { Err(e) => {
eprintln!("Uh oh! The file-exists check couldn't be done: {e}"); 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)"); panic!(
}, "TODO: Deal with scenario where the file's existence cannot be checked (e.g.: no permission)"
);
}
} }
} }
for file in files { for file in files {

View File

@@ -1,4 +1,3 @@
use colored::Colorize; use colored::Colorize;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@@ -35,7 +34,7 @@ impl Release {
}; };
format!( format!(
"{tag} {} "{tag} {}
{name} {} {name} {}
{} {}
{published} {} ({created} {}) {published} {} ({created} {})