From 9003b6a3e701d5044e52540cc0ad341d045ec3a9 Mon Sep 17 00:00:00 2001 From: softprops Date: Sun, 25 Aug 2019 21:59:02 -0400 Subject: [PATCH] print status of uploads --- src/github.rs | 23 ++++++++++++----------- src/main.rs | 11 +++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/github.rs b/src/github.rs index b1185ac..1532f10 100644 --- a/src/github.rs +++ b/src/github.rs @@ -37,7 +37,7 @@ pub trait AssetUploader = File> { release_id: usize, mime: Mime, asset: A, - ) -> Result<(), Box>; + ) -> Result>; } impl Releaser for Client { @@ -87,16 +87,17 @@ impl> AssetUploader for Client { release_id: usize, mime: mime::Mime, asset: A, - ) -> Result<(), Box> { - self.post(&format!( - "http://uploads.github.com/repos/{}/releases/{}", - github_repo, release_id - )) - .header("Authorization", format!("bearer {}", github_token)) - .header("Content-Type", mime.to_string()) - .body(asset) - .send()?; - Ok(()) + ) -> Result> { + Ok(self + .post(&format!( + "http://uploads.github.com/repos/{}/releases/{}", + github_repo, release_id + )) + .header("Authorization", format!("bearer {}", github_token)) + .header("Content-Type", mime.to_string()) + .body(asset) + .send()? + .status()) } } diff --git a/src/main.rs b/src/main.rs index cd5209f..bc439dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -87,24 +87,23 @@ fn run( conf.github_repository.as_str(), release(&conf), )?; - println!("name {:#?}", conf.input_name); - println!("files {:#?}", conf.input_files); if let Some(patterns) = conf.input_files { for path in paths(patterns)? { println!("⬆️ Uploading asset {}", path.display()); - uploader.upload( + let status = uploader.upload( conf.github_token.as_str(), conf.github_repository.as_str(), id, mime_or_default(&path), File::open(path)?, )?; + println!("uploaded with status {}", status); } - - println!("🎉 Release ready at {}", html_url); } + println!("🎉 Release ready at {}", html_url); + Ok(()) } @@ -187,7 +186,7 @@ mod tests { github_repository: "foo/bar".into(), input_name: Some("test release".into()), input_body: Some(":)".into()), - input_files: Some(vec!["*.md".into()]) + input_files: Some(vec!["*.md".into()]), }, )] { assert_eq!(expect, envy::from_iter::<_, Config>(env)?)