mirror of
https://github.com/orhun/git-cliff.git
synced 2024-11-25 08:37:40 +03:00
refactor(cli): make update-informer opt-out via feature flag (#69)
This commit is contained in:
parent
efd40e02b3
commit
cddb4d49fb
@ -16,12 +16,15 @@ edition = "2021"
|
||||
name = "git-cliff-completions"
|
||||
path = "src/bin/completions.rs"
|
||||
|
||||
[features]
|
||||
# check for new versions
|
||||
default = ["update-informer"]
|
||||
|
||||
[dependencies]
|
||||
pretty_env_logger = "0.4.0"
|
||||
log = "0.4.14"
|
||||
dirs-next = "2.0.0"
|
||||
clap_complete = "3.1.1"
|
||||
update-informer = "0.5.0"
|
||||
|
||||
[dependencies.git-cliff-core]
|
||||
version = "0.6.1" # managed by release.sh
|
||||
@ -31,5 +34,9 @@ path = "../git-cliff-core"
|
||||
version = "3.1.6"
|
||||
features = ["derive", "env", "wrap_help"]
|
||||
|
||||
[dependencies.update-informer]
|
||||
version = "0.5.0"
|
||||
optional = true
|
||||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "1.1.0"
|
||||
|
@ -29,14 +29,18 @@ use std::fs::{
|
||||
File,
|
||||
};
|
||||
use std::io;
|
||||
use update_informer::registry::Crates;
|
||||
use update_informer::Check;
|
||||
|
||||
/// Checks for a new version on crates.io
|
||||
#[cfg(feature = "update-informer")]
|
||||
fn check_new_version() {
|
||||
use update_informer::Check;
|
||||
let pkg_name = env!("CARGO_PKG_NAME");
|
||||
let pkg_version = env!("CARGO_PKG_VERSION");
|
||||
let informer = update_informer::new(Crates, pkg_name, pkg_version);
|
||||
let informer = update_informer::new(
|
||||
update_informer::registry::Crates,
|
||||
pkg_name,
|
||||
pkg_version,
|
||||
);
|
||||
if let Some(new_version) = informer.check_version().ok().flatten() {
|
||||
log::info!(
|
||||
"A new version of {pkg_name} is available: v{pkg_version} -> \
|
||||
@ -48,6 +52,7 @@ fn check_new_version() {
|
||||
/// Runs `git-cliff`.
|
||||
pub fn run(mut args: Opt) -> Result<()> {
|
||||
// Check if there is a new version available.
|
||||
#[cfg(feature = "update-informer")]
|
||||
check_new_version();
|
||||
|
||||
// Create the configuration file if init flag is given.
|
||||
|
Loading…
Reference in New Issue
Block a user