diff --git a/Cargo.lock b/Cargo.lock index 02df8b23..3911875a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3107,7 +3107,6 @@ dependencies = [ "futures-util", "futures_codec", "getset", - "git2", "glob", "heim", "htmlescape", @@ -3211,7 +3210,6 @@ dependencies = [ "futures-util", "futures_codec", "getset", - "git2", "glob", "heim", "htmlescape", @@ -5217,9 +5215,9 @@ dependencies = [ [[package]] name = "shadow-rs" -version = "0.5.8" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48d36234bd8117223aa622e2ab8aa530f4db4e48f651c2afd445cc3178b4ecdb" +checksum = "0d5d44a3b9d42450685af2c83260ea5573430c47f011a9e26093d3839af74a31" dependencies = [ "chrono", "git2", diff --git a/Cargo.toml b/Cargo.toml index 115635a8..0196ba3f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -65,7 +65,6 @@ nu-test-support = {version = "0.25.2", path = "./crates/nu-test-support"} [features] ctrlc-support = ["nu-cli/ctrlc", "nu-command/ctrlc"] directories-support = ["nu-cli/directories", "nu-cli/dirs", "nu-command/directories", "nu-command/dirs", "nu-data/directories", "nu-data/dirs", "nu-engine/dirs"] -git-support = ["nu-cli/git2", "nu-command/git2"] ptree-support = ["nu-cli/ptree", "nu-command/ptree"] rich-benchmark = ["nu-cli/rich-benchmark", "nu-command/rich-benchmark"] rustyline-support = ["nu-cli/rustyline-support", "nu-command/rustyline-support"] @@ -78,7 +77,6 @@ default = [ "ps", "textview", "inc", - "git-support", "directories-support", "ctrlc-support", "which-support", diff --git a/crates/nu-cli/Cargo.toml b/crates/nu-cli/Cargo.toml index 1c3b81ba..b2d1a64f 100644 --- a/crates/nu-cli/Cargo.toml +++ b/crates/nu-cli/Cargo.toml @@ -11,67 +11,66 @@ version = "0.25.2" doctest = false [dependencies] -nu-command = {version = "0.25.2", path = "../nu-command"} -nu-data = {version = "0.25.2", path = "../nu-data"} -nu-engine = {version = "0.25.2", path = "../nu-engine"} -nu-errors = {version = "0.25.2", path = "../nu-errors"} -nu-json = {version = "0.25.2", path = "../nu-json"} -nu-parser = {version = "0.25.2", path = "../nu-parser"} -nu-plugin = {version = "0.25.2", path = "../nu-plugin"} -nu-protocol = {version = "0.25.2", path = "../nu-protocol"} -nu-source = {version = "0.25.2", path = "../nu-source"} -nu-stream = {version = "0.25.2", path = "../nu-stream"} -nu-table = {version = "0.25.2", path = "../nu-table"} -nu-test-support = {version = "0.25.2", path = "../nu-test-support"} -nu-value-ext = {version = "0.25.2", path = "../nu-value-ext"} +nu-command = { version = "0.25.2", path = "../nu-command" } +nu-data = { version = "0.25.2", path = "../nu-data" } +nu-engine = { version = "0.25.2", path = "../nu-engine" } +nu-errors = { version = "0.25.2", path = "../nu-errors" } +nu-json = { version = "0.25.2", path = "../nu-json" } +nu-parser = { version = "0.25.2", path = "../nu-parser" } +nu-plugin = { version = "0.25.2", path = "../nu-plugin" } +nu-protocol = { version = "0.25.2", path = "../nu-protocol" } +nu-source = { version = "0.25.2", path = "../nu-source" } +nu-stream = { version = "0.25.2", path = "../nu-stream" } +nu-table = { version = "0.25.2", path = "../nu-table" } +nu-test-support = { version = "0.25.2", path = "../nu-test-support" } +nu-value-ext = { version = "0.25.2", path = "../nu-value-ext" } Inflector = "0.11" ansi_term = "0.12.1" -arboard = {version = "1.1.0", optional = true} +arboard = { version = "1.1.0", optional = true } async-recursion = "0.3.1" async-trait = "0.1.40" base64 = "0.13.0" -bigdecimal = {version = "0.2.0", features = ["serde"]} +bigdecimal = { version = "0.2.0", features = ["serde"] } byte-unit = "4.0.9" bytes = "0.5.6" calamine = "0.16.1" -chrono = {version = "0.4.15", features = ["serde"]} +chrono = { version = "0.4.15", features = ["serde"] } chrono-tz = "0.5.3" clap = "2.33.3" codespan-reporting = "0.11.0" csv = "1.1.3" -ctrlc = {version = "3.1.6", optional = true} +ctrlc = { version = "3.1.6", optional = true } derive-new = "0.5.8" -directories = {version = "3.0.1", optional = true} -dirs = {version = "3.0.1", optional = true} +directories = { version = "3.0.1", optional = true } +dirs = { version = "3.0.1", optional = true } dtparse = "1.2.0" dunce = "1.0.1" eml-parser = "0.1.0" encoding_rs = "0.8.24" filesize = "0.2.0" fs_extra = "1.2.0" -futures = {version = "0.3.5", features = ["compat", "io-compat"]} +futures = { version = "0.3.5", features = ["compat", "io-compat"] } futures-util = "0.3.8" futures_codec = "0.4.1" getset = "0.1.1" -git2 = {version = "0.13.11", default_features = false, optional = true} glob = "0.3.0" -heim = {version = "0.1.0-rc.1", optional = true} +heim = { version = "0.1.0-rc.1", optional = true } htmlescape = "0.3.1" ical = "0.7.0" -ichwh = {version = "0.3.4", optional = true} -indexmap = {version = "1.6.0", features = ["serde-1"]} +ichwh = { version = "0.3.4", optional = true } +indexmap = { version = "1.6.0", features = ["serde-1"] } itertools = "0.10.0" lazy_static = "1.*" log = "0.4.11" meval = "0.2.0" -num-bigint = {version = "0.3.0", features = ["serde"]} -num-format = {version = "0.4.0", features = ["with-num-bigint"]} +num-bigint = { version = "0.3.0", features = ["serde"] } +num-format = { version = "0.4.0", features = ["with-num-bigint"] } num-traits = "0.2.12" parking_lot = "0.11.0" pin-utils = "0.1.0" pretty-hex = "0.2.0" -ptree = {version = "0.3.0", optional = true} +ptree = { version = "0.3.0", optional = true } query_interface = "0.3.5" quick-xml = "0.20.0" rand = "0.7.3" @@ -79,8 +78,8 @@ rayon = "1.4.0" regex = "1.3.9" roxmltree = "0.14.0" rust-embed = "5.8.0" -rustyline = {version = "6.3.0", optional = true} -serde = {version = "1.0.115", features = ["derive"]} +rustyline = { version = "6.3.0", optional = true } +serde = { version = "1.0.115", features = ["derive"] } serde_bytes = "0.11.5" serde_ini = "0.2.0" serde_json = "1.0.57" @@ -92,18 +91,19 @@ strip-ansi-escapes = "0.1.0" sxd-document = "0.3.2" sxd-xpath = "0.4.2" tempfile = "3.1.0" -term = {version = "0.6.1", optional = true} +term = { version = "0.6.1", optional = true } term_size = "0.3.2" termcolor = "1.1.0" titlecase = "1.0" toml = "0.5.6" -trash = {version = "1.2.0", optional = true} +trash = { version = "1.2.0", optional = true } unicode-segmentation = "1.6.0" -uom = {version = "0.30.0", features = ["f64", "try-from"]} +uom = { version = "0.30.0", features = ["f64", "try-from"] } url = "2.1.1" -uuid_crate = {package = "uuid", version = "0.8.1", features = ["v4"], optional = true} -which = {version = "4.0.2", optional = true} -zip = {version = "0.5.7", optional = true} +uuid_crate = { package = "uuid", version = "0.8.1", features = ["v4"], optional = true } +which = { version = "4.0.2", optional = true } +zip = { version = "0.5.7", optional = true } +shadow-rs = { version = "0.5", default-features = false, optional = true } [target.'cfg(unix)'.dependencies] umask = "1.0.0" @@ -128,6 +128,7 @@ quickcheck = "0.9.2" quickcheck_macros = "0.9.1" [features] +default = ["shadow-rs"] clipboard-cli = ["arboard"] rich-benchmark = ["heim"] rustyline-support = ["rustyline", "nu-engine/rustyline-support"] diff --git a/crates/nu-cli/src/cli.rs b/crates/nu-cli/src/cli.rs index 4f613b1d..991c8d1a 100644 --- a/crates/nu-cli/src/cli.rs +++ b/crates/nu-cli/src/cli.rs @@ -163,17 +163,9 @@ pub async fn cli(mut context: EvaluationContext) -> Result<(), Box> { let (prompt_block, err) = nu_parser::parse(&prompt_line, 0, &context.scope); if err.is_some() { - use crate::git::current_branch; context.scope.exit_scope(); - format!( - "\x1b[32m{}{}\x1b[m> ", - cwd, - match current_branch() { - Some(s) => format!("({})", s), - None => "".to_string(), - } - ) + format!("\x1b[32m{}{}\x1b[m> ", cwd, current_branch()) } else { // let env = context.get_env(); @@ -209,15 +201,7 @@ pub async fn cli(mut context: EvaluationContext) -> Result<(), Box> { } } } else { - use crate::git::current_branch; - format!( - "\x1b[32m{}{}\x1b[m> ", - cwd, - match current_branch() { - Some(s) => format!("({})", s), - None => "".to_string(), - } - ) + format!("\x1b[32m{}{}\x1b[m> ", cwd, current_branch()) } }; @@ -371,7 +355,7 @@ async fn run_startup_commands( _ => { return Err(ShellError::untagged_runtime_error( "expected a table of pipeline strings as startup commands", - )) + )); } } } @@ -405,6 +389,22 @@ pub async fn parse_and_eval(line: &str, ctx: &EvaluationContext) -> Result String { + #[cfg(feature = "shadow-rs")] + { + Some(shadow_rs::branch()) + .map(|x| x.trim().to_string()) + .filter(|x| !x.is_empty()) + .map(|x| format!("({})", x)) + .unwrap_or_default() + } + #[cfg(not(feature = "shadow-rs"))] + { + "".to_string() + } +} + #[cfg(test)] mod tests { use nu_engine::basic_evaluation_context; diff --git a/crates/nu-cli/src/git.rs b/crates/nu-cli/src/git.rs deleted file mode 100644 index a979c24f..00000000 --- a/crates/nu-cli/src/git.rs +++ /dev/null @@ -1,26 +0,0 @@ -pub fn current_branch() -> Option { - #[cfg(feature = "git2")] - { - use git2::{Repository, RepositoryOpenFlags}; - use std::ffi::OsString; - - let v: Vec = vec![]; - match Repository::open_ext(".", RepositoryOpenFlags::empty(), v) { - Ok(repo) => { - let r = repo.head(); - match r { - Ok(r) => match r.shorthand() { - Some(s) => Some(s.to_string()), - None => None, - }, - _ => None, - } - } - _ => None, - } - } - #[cfg(not(feature = "git2"))] - { - None - } -} diff --git a/crates/nu-cli/src/lib.rs b/crates/nu-cli/src/lib.rs index 4afa294f..8069da20 100644 --- a/crates/nu-cli/src/lib.rs +++ b/crates/nu-cli/src/lib.rs @@ -19,8 +19,6 @@ mod completion; mod env; mod format; #[cfg(feature = "rustyline-support")] -mod git; -#[cfg(feature = "rustyline-support")] mod keybinding; mod line_editor; mod shell; diff --git a/crates/nu-command/Cargo.toml b/crates/nu-command/Cargo.toml index 9734bccc..b54f56d1 100644 --- a/crates/nu-command/Cargo.toml +++ b/crates/nu-command/Cargo.toml @@ -11,66 +11,65 @@ version = "0.25.2" doctest = false [dependencies] -nu-data = {version = "0.25.2", path = "../nu-data"} -nu-engine = {version = "0.25.2", path = "../nu-engine"} -nu-errors = {version = "0.25.2", path = "../nu-errors"} -nu-json = {version = "0.25.2", path = "../nu-json"} -nu-parser = {version = "0.25.2", path = "../nu-parser"} -nu-plugin = {version = "0.25.2", path = "../nu-plugin"} -nu-protocol = {version = "0.25.2", path = "../nu-protocol"} -nu-source = {version = "0.25.2", path = "../nu-source"} -nu-stream = {version = "0.25.2", path = "../nu-stream"} -nu-table = {version = "0.25.2", path = "../nu-table"} -nu-test-support = {version = "0.25.2", path = "../nu-test-support"} -nu-value-ext = {version = "0.25.2", path = "../nu-value-ext"} +nu-data = { version = "0.25.2", path = "../nu-data" } +nu-engine = { version = "0.25.2", path = "../nu-engine" } +nu-errors = { version = "0.25.2", path = "../nu-errors" } +nu-json = { version = "0.25.2", path = "../nu-json" } +nu-parser = { version = "0.25.2", path = "../nu-parser" } +nu-plugin = { version = "0.25.2", path = "../nu-plugin" } +nu-protocol = { version = "0.25.2", path = "../nu-protocol" } +nu-source = { version = "0.25.2", path = "../nu-source" } +nu-stream = { version = "0.25.2", path = "../nu-stream" } +nu-table = { version = "0.25.2", path = "../nu-table" } +nu-test-support = { version = "0.25.2", path = "../nu-test-support" } +nu-value-ext = { version = "0.25.2", path = "../nu-value-ext" } Inflector = "0.11" ansi_term = "0.12.1" -arboard = {version = "1.1.0", optional = true} +arboard = { version = "1.1.0", optional = true } async-recursion = "0.3.1" async-trait = "0.1.40" base64 = "0.13.0" -bigdecimal = {version = "0.2.0", features = ["serde"]} +bigdecimal = { version = "0.2.0", features = ["serde"] } byte-unit = "4.0.9" bytes = "0.5.6" calamine = "0.16.1" -chrono = {version = "0.4.15", features = ["serde"]} +chrono = { version = "0.4.15", features = ["serde"] } chrono-tz = "0.5.3" clap = "2.33.3" codespan-reporting = "0.11.0" csv = "1.1.3" -ctrlc = {version = "3.1.6", optional = true} +ctrlc = { version = "3.1.6", optional = true } derive-new = "0.5.8" -directories = {version = "3.0.1", optional = true} -dirs = {version = "3.0.1", optional = true} +directories = { version = "3.0.1", optional = true } +dirs = { version = "3.0.1", optional = true } dtparse = "1.2.0" dunce = "1.0.1" eml-parser = "0.1.0" encoding_rs = "0.8.24" filesize = "0.2.0" fs_extra = "1.2.0" -futures = {version = "0.3.5", features = ["compat", "io-compat"]} +futures = { version = "0.3.5", features = ["compat", "io-compat"] } futures-util = "0.3.8" futures_codec = "0.4.1" getset = "0.1.1" -git2 = {version = "0.13.11", default_features = false, optional = true} glob = "0.3.0" -heim = {version = "0.1.0-rc.1", optional = true} +heim = { version = "0.1.0-rc.1", optional = true } htmlescape = "0.3.1" ical = "0.7.0" -ichwh = {version = "0.3.4", optional = true} -indexmap = {version = "1.6.0", features = ["serde-1"]} +ichwh = { version = "0.3.4", optional = true } +indexmap = { version = "1.6.0", features = ["serde-1"] } itertools = "0.10.0" lazy_static = "1.*" log = "0.4.11" meval = "0.2.0" -num-bigint = {version = "0.3.0", features = ["serde"]} -num-format = {version = "0.4.0", features = ["with-num-bigint"]} +num-bigint = { version = "0.3.0", features = ["serde"] } +num-format = { version = "0.4.0", features = ["with-num-bigint"] } num-traits = "0.2.12" parking_lot = "0.11.0" pin-utils = "0.1.0" pretty-hex = "0.2.0" -ptree = {version = "0.3.0", optional = true} +ptree = { version = "0.3.0", optional = true } query_interface = "0.3.5" quick-xml = "0.20.0" rand = "0.7.3" @@ -78,8 +77,8 @@ rayon = "1.4.0" regex = "1.3.9" roxmltree = "0.14.0" rust-embed = "5.8.0" -rustyline = {version = "6.3.0", optional = true} -serde = {version = "1.0.115", features = ["derive"]} +rustyline = { version = "6.3.0", optional = true } +serde = { version = "1.0.115", features = ["derive"] } serde_bytes = "0.11.5" serde_ini = "0.2.0" serde_json = "1.0.57" @@ -91,18 +90,18 @@ strip-ansi-escapes = "0.1.0" sxd-document = "0.3.2" sxd-xpath = "0.4.2" tempfile = "3.1.0" -term = {version = "0.6.1", optional = true} +term = { version = "0.6.1", optional = true } term_size = "0.3.2" termcolor = "1.1.0" titlecase = "1.0" toml = "0.5.6" -trash = {version = "1.2.0", optional = true} +trash = { version = "1.2.0", optional = true } unicode-segmentation = "1.6.0" -uom = {version = "0.30.0", features = ["f64", "try-from"]} +uom = { version = "0.30.0", features = ["f64", "try-from"] } url = "2.1.1" -uuid_crate = {package = "uuid", version = "0.8.1", features = ["v4"], optional = true} -which = {version = "4.0.2", optional = true} -zip = {version = "0.5.7", optional = true} +uuid_crate = { package = "uuid", version = "0.8.1", features = ["v4"], optional = true } +which = { version = "4.0.2", optional = true } +zip = { version = "0.5.7", optional = true } [target.'cfg(unix)'.dependencies] umask = "1.0.0" diff --git a/crates/nu-command/src/commands/version.rs b/crates/nu-command/src/commands/version.rs index c6de617f..0eab0a55 100644 --- a/crates/nu-command/src/commands/version.rs +++ b/crates/nu-command/src/commands/version.rs @@ -165,11 +165,6 @@ fn features_enabled() -> Vec { names.push("directories".to_string()); } - #[cfg(feature = "git2")] - { - names.push("git".to_string()); - } - #[cfg(feature = "ptree")] { names.push("ptree".to_string()); diff --git a/docs/commands/to-toml.md b/docs/commands/to-toml.md index 674c94f0..63693a94 100644 --- a/docs/commands/to-toml.md +++ b/docs/commands/to-toml.md @@ -58,7 +58,6 @@ dunce = "1.0.0" futures-sink-preview = "0.3.0-alpha.16" futures_codec = "0.2.2" getset = "0.0.7" -git2 = "0.8.0" itertools = "0.8.0" lalrpop-util = "0.17.0" language-reporting = "0.3.0" diff --git a/tests/fixtures/formats/cargo_sample.toml b/tests/fixtures/formats/cargo_sample.toml index 751f3ab9..cd480d86 100644 --- a/tests/fixtures/formats/cargo_sample.toml +++ b/tests/fixtures/formats/cargo_sample.toml @@ -47,7 +47,6 @@ directories = "2.0.2" toml = "0.5.1" toml-query = "0.9.0" clap = "2.33.0" -git2 = "0.8.0" [dependencies.pancurses] version = "0.16"