From ee54107d2a3f5386859b489ff59dbb3b85809456 Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Sun, 23 Dec 2018 13:17:53 +0200 Subject: [PATCH] Print the changelog when updating --- Cargo.lock | 6 +++--- Cargo.toml | 3 +++ src/main.rs | 3 +++ src/self_update.rs | 10 ++++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 32028796..25391333 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1094,7 +1094,7 @@ dependencies = [ [[package]] name = "self_update" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/r-darwish/self_update?branch=github-extended#e0408201c5ad575a6a4b70e49882a0a5f6a213d6" dependencies = [ "either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "flate2 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1496,7 +1496,7 @@ dependencies = [ "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.12.0 (registry+https://github.com/rust-lang/crates.io-index)", - "self_update 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "self_update 0.5.0 (git+https://github.com/r-darwish/self_update?branch=github-extended)", "serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)", "shellexpand 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1839,7 +1839,7 @@ dependencies = [ "checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27" "checksum security-framework 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "697d3f3c23a618272ead9e1fb259c1411102b31c6af8b93f1d64cca9c3b0e8e0" "checksum security-framework-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ab01dfbe5756785b5b4d46e0289e5a18071dfa9a7c2b24213ea00b9ef9b665bf" -"checksum self_update 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4a91301ec87d3925a64c06f667a2f244cf4edb7bd512b1e0aa72abc1963141e3" +"checksum self_update 0.5.0 (git+https://github.com/r-darwish/self_update?branch=github-extended)" = "" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)" = "6fa52f19aee12441d5ad11c9a00459122bd8f98707cadf9778c540674f1935b6" diff --git a/Cargo.toml b/Cargo.toml index 2fa29398..a006ad0f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,9 @@ nix = "0.12.0" [profile.release] lto = true +[patch.crates-io] +self_update = { git = "https://github.com/r-darwish/self_update", branch = "github-extended" } + [features] default = [] diff --git a/src/main.rs b/src/main.rs index 47f71402..00054bbb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,6 +76,9 @@ fn run() -> Result<(), Error> { if !opt.dry_run { if let Err(e) = self_update::self_update() { print_warning(format!("Self update error: {}", e)); + if let Some(cause) = e.cause() { + print_warning(format!("Caused by: {}", cause)); + } } } } diff --git a/src/self_update.rs b/src/self_update.rs index fe5a6ade..32108966 100644 --- a/src/self_update.rs +++ b/src/self_update.rs @@ -2,6 +2,7 @@ use super::error::{Error, ErrorKind}; use super::terminal::*; use failure::ResultExt; use self_update_crate; +use self_update_crate::backends::github::{GitHubUpdateStatus, Update}; #[cfg(unix)] use std::env; #[cfg(unix)] @@ -15,7 +16,7 @@ pub fn self_update() -> Result<(), Error> { let current_exe = env::current_exe(); let target = self_update_crate::get_target().context(ErrorKind::SelfUpdate)?; - let result = self_update_crate::backends::github::Update::configure() + let result = Update::configure() .context(ErrorKind::SelfUpdate)? .repo_owner("r-darwish") .repo_name("topgrade") @@ -27,11 +28,12 @@ pub fn self_update() -> Result<(), Error> { .no_confirm(true) .build() .context(ErrorKind::SelfUpdate)? - .update() + .update2() .context(ErrorKind::SelfUpdate)?; - if let self_update_crate::Status::Updated(version) = &result { - println!("\nTopgrade upgraded to {}", version); + if let GitHubUpdateStatus::Updated(release) = &result { + println!("\nTopgrade upgraded to {}:\n", release.version()); + println!("{}", release.body); } else { println!("Topgrade is up-to-date"); }