Print the changelog when updating

This commit is contained in:
Roey Darwish Dror
2018-12-23 13:17:53 +02:00
parent badc6b665b
commit ee54107d2a
4 changed files with 15 additions and 7 deletions

6
Cargo.lock generated
View File

@@ -1094,7 +1094,7 @@ dependencies = [
[[package]] [[package]]
name = "self_update" name = "self_update"
version = "0.5.0" 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 = [ dependencies = [
"either 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "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)", "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)", "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)", "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 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)", "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)", "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 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 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 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)" = "<none>"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "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 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" "checksum serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)" = "6fa52f19aee12441d5ad11c9a00459122bd8f98707cadf9778c540674f1935b6"

View File

@@ -31,6 +31,9 @@ nix = "0.12.0"
[profile.release] [profile.release]
lto = true lto = true
[patch.crates-io]
self_update = { git = "https://github.com/r-darwish/self_update", branch = "github-extended" }
[features] [features]
default = [] default = []

View File

@@ -76,6 +76,9 @@ fn run() -> Result<(), Error> {
if !opt.dry_run { if !opt.dry_run {
if let Err(e) = self_update::self_update() { if let Err(e) = self_update::self_update() {
print_warning(format!("Self update error: {}", e)); print_warning(format!("Self update error: {}", e));
if let Some(cause) = e.cause() {
print_warning(format!("Caused by: {}", cause));
}
} }
} }
} }

View File

@@ -2,6 +2,7 @@ use super::error::{Error, ErrorKind};
use super::terminal::*; use super::terminal::*;
use failure::ResultExt; use failure::ResultExt;
use self_update_crate; use self_update_crate;
use self_update_crate::backends::github::{GitHubUpdateStatus, Update};
#[cfg(unix)] #[cfg(unix)]
use std::env; use std::env;
#[cfg(unix)] #[cfg(unix)]
@@ -15,7 +16,7 @@ pub fn self_update() -> Result<(), Error> {
let current_exe = env::current_exe(); let current_exe = env::current_exe();
let target = self_update_crate::get_target().context(ErrorKind::SelfUpdate)?; 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)? .context(ErrorKind::SelfUpdate)?
.repo_owner("r-darwish") .repo_owner("r-darwish")
.repo_name("topgrade") .repo_name("topgrade")
@@ -27,11 +28,12 @@ pub fn self_update() -> Result<(), Error> {
.no_confirm(true) .no_confirm(true)
.build() .build()
.context(ErrorKind::SelfUpdate)? .context(ErrorKind::SelfUpdate)?
.update() .update2()
.context(ErrorKind::SelfUpdate)?; .context(ErrorKind::SelfUpdate)?;
if let self_update_crate::Status::Updated(version) = &result { if let GitHubUpdateStatus::Updated(release) = &result {
println!("\nTopgrade upgraded to {}", version); println!("\nTopgrade upgraded to {}:\n", release.version());
println!("{}", release.body);
} else { } else {
println!("Topgrade is up-to-date"); println!("Topgrade is up-to-date");
} }