From 16f75632fbcc13c008234521dfcb984f5246b36f Mon Sep 17 00:00:00 2001 From: sagie gur ari Date: Thu, 10 Aug 2023 08:15:38 +0000 Subject: [PATCH 1/2] Replace unmaintained ansi_term with nu_ansi_term #913 --- CHANGELOG.md | 3 ++- Cargo.lock | 20 ++++++++++---------- Cargo.toml | 2 +- src/lib/mod.rs | 2 +- src/makers.rs | 2 +- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b46f7887..a28e429c8 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ ## CHANGELOG -### draft +### v0.36.13 * Fix: Auto complete bash script #914 (thanks @gw31415) * Documentation: Arch Linux installation #880 (thanks @CosminGGeorgescu) * Documentation: Fix Readme about Binary Release Target #915 (thanks @Azuki-bar) +* Maintenance: Replace unmaintained ansi_term with nu_ansi_term #913 ### v0.36.12 (2023-07-19) diff --git a/Cargo.lock b/Cargo.lock index c2c82a60c..8da600dc4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,15 +32,6 @@ dependencies = [ "libc", ] -[[package]] -name = "ansi_term" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" -dependencies = [ - "winapi", -] - [[package]] name = "attohttpc" version = "0.25.0" @@ -152,7 +143,6 @@ dependencies = [ name = "cargo-make" version = "0.36.12" dependencies = [ - "ansi_term", "cargo_metadata", "ci_info", "cliparser", @@ -173,6 +163,7 @@ dependencies = [ "itertools", "lenient_semver", "log", + "nu-ansi-term", "once_cell", "petgraph", "regex", @@ -909,6 +900,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "nu-ansi-term" +version = "0.49.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c073d3c1930d0751774acf49e66653acecb416c3a54c6ec095a9b11caddb5a68" +dependencies = [ + "windows-sys", +] + [[package]] name = "num-traits" version = "0.2.15" diff --git a/Cargo.toml b/Cargo.toml index fbabfa3d9..e73b74fa7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -80,7 +80,7 @@ toml = "^0.7" expect-test = "^1" [target.'cfg(windows)'.dependencies] -ansi_term = "^0.12.1" +nu-ansi-term = "^0.49" [features] tls-rustls = ["duckscriptsdk/tls-rustls"] diff --git a/src/lib/mod.rs b/src/lib/mod.rs index 7de30d917..62264da85 100755 --- a/src/lib/mod.rs +++ b/src/lib/mod.rs @@ -201,7 +201,7 @@ // Dependencies used in the binary `makers`: #[cfg(windows)] -use ansi_term as _; +use nu_ansi_term as _; #[macro_use] extern crate log; diff --git a/src/makers.rs b/src/makers.rs index abbd6117e..f30621fd3 100644 --- a/src/makers.rs +++ b/src/makers.rs @@ -22,7 +22,7 @@ fn get_name() -> String { fn main() { #[cfg(windows)] - let _ = ansi_term::enable_ansi_support(); + let _ = nu_ansi_term::enable_ansi_support(); let name = get_name(); cli::run_cli(name, false); } From e53fdf32f78af0d249606e7cfdd0f213e324c191 Mon Sep 17 00:00:00 2001 From: sagie gur ari Date: Thu, 10 Aug 2023 09:22:20 +0000 Subject: [PATCH 2/2] Fix: External env vars are detected as cycles #911 --- CHANGELOG.md | 1 + Cargo.lock | 150 +++++++++++++-------------------- src/lib/cli.rs | 12 +-- src/lib/descriptor/env.rs | 4 +- src/lib/descriptor/env_test.rs | 40 +++++++++ src/lib/descriptor/mod.rs | 6 +- src/lib/descriptor/mod_test.rs | 7 +- 7 files changed, 115 insertions(+), 105 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a28e429c8..87d73bd90 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### v0.36.13 +* Fix: External env vars are detected as cycles #911 * Fix: Auto complete bash script #914 (thanks @gw31415) * Documentation: Arch Linux installation #880 (thanks @CosminGGeorgescu) * Documentation: Fix Readme about Binary Release Target #915 (thanks @Azuki-bar) diff --git a/Cargo.lock b/Cargo.lock index 8da600dc4..97f6eff5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,9 +10,9 @@ checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "aho-corasick" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43f6cb1bf222025340178f382c426f13757b2960e89779dfcb319c32542a5a41" +checksum = "86b8f9420f797f2d9e935edf629310eb938a0d839f984e25327f3c7eed22300c" dependencies = [ "memchr", ] @@ -203,9 +203,12 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.79" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" +checksum = "305fe645edc1442a0fa8b6726ba61d422798d37a52e12eaecf4b022ebbb88f01" +dependencies = [ + "libc", +] [[package]] name = "cfg-if" @@ -314,6 +317,12 @@ dependencies = [ "windows-sys", ] +[[package]] +name = "deranged" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7684a49fb1af197853ef7b2ee694bc1f5b4179556f1e5710e1760c5db6f5e929" + [[package]] name = "digest" version = "0.10.7" @@ -400,9 +409,9 @@ checksum = "56ce8c6da7551ec6c462cbaf3bfbc75131ebbfa1c944aeaa9dab51ca1c5f0c3b" [[package]] name = "either" -version = "1.8.1" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" +checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "encoding_rs" @@ -431,9 +440,9 @@ checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "errno" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +checksum = "6b30f669a7961ef1631673d2766cc92f52d64f7ef354d4fe0ddfd30ed52f0f4f" dependencies = [ "errno-dragonfly", "libc", @@ -452,9 +461,9 @@ dependencies = [ [[package]] name = "evalexpr" -version = "11.0.0" +version = "11.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec3b4e80fd8edee77d6fc35d59862d5765dae7512a95f49fd7bf03847c85b26a" +checksum = "8adeb24130b6ffd6a2f4d2768c8cbf28d98b115c9f576896bb3d6926c2296927" [[package]] name = "expect-test" @@ -468,12 +477,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "1.9.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" -dependencies = [ - "instant", -] +checksum = "6999dc1837253364c2ebb0704ba97994bd874e8f195d665c50b7548f6ea92764" [[package]] name = "fern" @@ -581,9 +587,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.11" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1391ab1f92ffcc08911957149833e682aa3fe252b9f45f966d2ef972274c97df" +checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" dependencies = [ "aho-corasick", "bstr", @@ -707,26 +713,6 @@ dependencies = [ "serde", ] -[[package]] -name = "instant" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eae7b9aee968036d54dce06cebaefd919e4472e753296daccd6d344e3e2df0c2" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys", -] - [[package]] name = "is-terminal" version = "0.4.9" @@ -734,7 +720,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "rustix 0.38.4", + "rustix", "windows-sys", ] @@ -839,15 +825,9 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "linux-raw-sys" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" - -[[package]] -name = "linux-raw-sys" -version = "0.4.3" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" +checksum = "57bcfdad1b858c2db7c38303a6d2ad4dfaf5eb53dfeb0910128b2c26d6158503" [[package]] name = "log" @@ -911,9 +891,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +checksum = "f30b0abd723be7e2ffca1272140fac1a2f084c77ec3e123c192b66af1ee9e6c2" dependencies = [ "autocfg", ] @@ -936,9 +916,9 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "openssl" -version = "0.10.55" +version = "0.10.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345df152bc43501c5eb9e4654ff05f794effb78d4efe3d53abc158baddc0703d" +checksum = "729b745ad4a5575dd06a3e1af1414bd330ee561c01b3899eb584baeaa8def17e" dependencies = [ "bitflags 1.3.2", "cfg-if", @@ -968,9 +948,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.90" +version = "0.9.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "374533b0e45f3a7ced10fcaeccca020e66656bc03dac384f852e4e5a7a8104a6" +checksum = "866b5f16f90776b9bb8dc1e1802ac6f0513de3a7a7465867bfbc563dc737faac" dependencies = [ "cc", "libc", @@ -1017,9 +997,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.31" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fe8a65d69dd0808184ebb5f836ab526bb259db23c657efa38711b1072ee47f0" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -1144,40 +1124,26 @@ checksum = "821495e93d15e4433347b3a72e97005f1d8a620dc88d46637fecfcb16e98043d" [[package]] name = "rustix" -version = "0.37.23" +version = "0.38.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d69718bf81c6127a49dc64e44a742e8bb9213c0ff8869a22c308f84c1d4ab06" -dependencies = [ - "bitflags 1.3.2", - "errno", - "io-lifetimes", - "libc", - "linux-raw-sys 0.3.8", - "windows-sys", -] - -[[package]] -name = "rustix" -version = "0.38.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" +checksum = "172891ebdceb05aa0005f533a6cbfca599ddd7d966f6f5d4d9b2e70478e70399" dependencies = [ "bitflags 2.3.3", "errno", "libc", - "linux-raw-sys 0.4.3", + "linux-raw-sys", "windows-sys", ] [[package]] name = "rustls" -version = "0.21.5" +version = "0.21.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79ea77c539259495ce8ca47f53e66ae0330a8819f67e23ac96ca02f50e7b7d36" +checksum = "1d1feddffcfcc0b33f5c6ce9a29e341e4cd59c3f78e7ee45f4a40c038b1d6cbb" dependencies = [ "log", "ring", - "rustls-webpki 0.101.1", + "rustls-webpki 0.101.3", "sct", ] @@ -1193,9 +1159,9 @@ dependencies = [ [[package]] name = "rustls-webpki" -version = "0.101.1" +version = "0.101.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "15f36a6828982f422756984e47912a7a51dcbc2a197aa791158f8ca61cd8204e" +checksum = "261e9e0888cba427c3316e6322805653c9425240b6fd96cee7cb671ab70ab8d0" dependencies = [ "ring", "untrusted", @@ -1237,9 +1203,9 @@ dependencies = [ [[package]] name = "security-framework" -version = "2.9.1" +version = "2.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fc758eb7bffce5b308734e9b0c1468893cae9ff70ebf13e7090be8dcbcc83a8" +checksum = "05b64fb303737d99b81884b2c63433e9ae28abebe5eb5045dcdd175dc2ecf4de" dependencies = [ "bitflags 1.3.2", "core-foundation", @@ -1250,9 +1216,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.9.0" +version = "2.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f51d0c0d83bec45f16480d0ce0058397a69e48fcdc52d1dc8855fb68acbd31a7" +checksum = "e932934257d3b408ed8f30db49d85ea163bfe74961f017f405b025af298f0c7a" dependencies = [ "core-foundation-sys", "libc", @@ -1384,32 +1350,31 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.6.0" +version = "3.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31c0432476357e58790aaa47a8efb0c5138f137343f3b5f23bd36a27e3b0a6d6" +checksum = "dc02fddf48964c42031a0b3fe0428320ecf3a73c401040fc0096f97794310651" dependencies = [ - "autocfg", "cfg-if", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.23", + "rustix", "windows-sys", ] [[package]] name = "thiserror" -version = "1.0.43" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a35fc5b8971143ca348fa6df4f024d4d55264f3468c71ad1c2f365b0a4d58c42" +checksum = "611040a08a0439f8248d1990b111c95baa9c704c805fa1f62104b39655fd7f90" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.43" +version = "1.0.44" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "463fe12d7993d3b327787537ce8dd4dfa058de32fc2b195ef3cde03dc4771e8f" +checksum = "090198534930841fab3a5d1bb637cde49e339654e606195f8d9c76eeb081dc96" dependencies = [ "proc-macro2", "quote", @@ -1428,10 +1393,11 @@ dependencies = [ [[package]] name = "time" -version = "0.3.23" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "59e399c068f43a5d116fedaf73b203fa4f9c519f17e2b34f63221d3792f81446" +checksum = "b0fdd63d58b18d663fbdf70e049f00a22c8e42be082203be7f26589213cd75ea" dependencies = [ + "deranged", "serde", "time-core", ] @@ -1784,9 +1750,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "winnow" -version = "0.5.0" +version = "0.5.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fac9742fd1ad1bd9643b991319f72dd031016d44b77039a26977eb667141e7" +checksum = "acaaa1190073b2b101e15083c38ee8ec891b5e05cbee516521e94ec008f61e64" dependencies = [ "memchr", ] diff --git a/src/lib/cli.rs b/src/lib/cli.rs index a7b3aec28..e27954834 100644 --- a/src/lib/cli.rs +++ b/src/lib/cli.rs @@ -99,15 +99,9 @@ fn run(cli_args: CliArgs, global_config: &GlobalConfig) { let config = match descriptor_load_result { Ok(config) => config, - Err(ref min_version) => { - error!( - "{} version: {} does not meet minimum required version: {}", - &cli_args.command, &VERSION, &min_version - ); - panic!( - "{} version: {} does not meet minimum required version: {}", - &cli_args.command, &VERSION, &min_version - ); + Err(ref error) => { + error!("{}", error); + panic!("{}", error); } }; let mut time_summary_vec = vec![]; diff --git a/src/lib/descriptor/env.rs b/src/lib/descriptor/env.rs index 481947c20..99bec98ea 100644 --- a/src/lib/descriptor/env.rs +++ b/src/lib/descriptor/env.rs @@ -142,8 +142,10 @@ pub(crate) fn merge_env( // if the env variable is in the current scope add an edge, // otherwise it is referencing an external variable. + // also, ignore self reference (such as PATH=${PATH}) + let is_external = envmnt::exists(&key); for used in env_depends_on(val).into_iter() { - if graph.contains_node(used) { + if (key != &used || !is_external) && graph.contains_node(used) { graph.add_edge(*key, used, ()); } } diff --git a/src/lib/descriptor/env_test.rs b/src/lib/descriptor/env_test.rs index 58e323b99..ee523811c 100644 --- a/src/lib/descriptor/env_test.rs +++ b/src/lib/descriptor/env_test.rs @@ -166,6 +166,46 @@ fn merge_env_cycle() { assert!(output.ends_with("env2 -> env1 -> env2.") || output.ends_with("env1 -> env2 -> env1.")); } +#[test] +fn merge_env_no_cycle_if_pointing_to_self_not_external() { + let map1 = IndexMap::::new(); + let mut map2 = IndexMap::::new(); + + map2.insert("test".to_string(), EnvValue::Value("${test}".to_string())); + + let output = merge_env(&map1, &map2).expect_err("should have cycle"); + assert!(output.ends_with("test -> test.")); +} + +#[test] +fn merge_env_no_cycle_if_pointing_to_self_external() { + let mut map1 = IndexMap::::new(); + let mut map2 = IndexMap::::new(); + + envmnt::set( + "merge_env_no_cycle_if_pointing_to_self_external", + "env_value", + ); + + map2.insert( + "merge_env_no_cycle_if_pointing_to_self_external".to_string(), + EnvValue::Value("${merge_env_no_cycle_if_pointing_to_self_external}".to_string()), + ); + + let output = merge_env(&mut map1, &mut map2).expect("should have no cycle"); + assert_eq!(output.len(), 1); + let value = output + .get("merge_env_no_cycle_if_pointing_to_self_external") + .unwrap(); + match value { + &EnvValue::Value(ref value_string) => assert_eq!( + value_string, + &"${merge_env_no_cycle_if_pointing_to_self_external}".to_string() + ), + _ => panic!("wrong value type"), + }; +} + #[test] fn merge_env_first_empty() { let mut map1 = IndexMap::::new(); diff --git a/src/lib/descriptor/mod.rs b/src/lib/descriptor/mod.rs index f126a7c95..65fd7e6cd 100755 --- a/src/lib/descriptor/mod.rs +++ b/src/lib/descriptor/mod.rs @@ -290,7 +290,11 @@ fn check_makefile_min_version(external_descriptor: &str) -> Result<(), String> { if let Some(ref min_version) = min_version { if version::is_newer_found(&min_version) { - return Err(min_version.to_string()); + return Err(format!( + "Unable to run, minimum required version is: {}", + &min_version + ) + .to_string()); } } diff --git a/src/lib/descriptor/mod_test.rs b/src/lib/descriptor/mod_test.rs index 0db30b88b..1f29a9f29 100755 --- a/src/lib/descriptor/mod_test.rs +++ b/src/lib/descriptor/mod_test.rs @@ -598,7 +598,7 @@ fn load_external_descriptor_min_version_broken_makefile_nopanic() { false ) .err(), - Some("999.999.999".into()) + Some("Unable to run, minimum required version is: 999.999.999".into()) ); } @@ -926,7 +926,10 @@ fn check_makefile_min_version_bigger_min_version() { let result = check_makefile_min_version(toml_string); assert!(result.is_err()); - assert_eq!(result.err().unwrap(), "999.999.999"); + assert_eq!( + result.err().unwrap(), + "Unable to run, minimum required version is: 999.999.999" + ); } #[test]