forked from extern/nushell
Replace git current_branch to shadow-rs branch (#2935)
* update to shadow-rs 0.4. use easy * update shadow-rs to 0.5 * fix version not used * update * update Cargo.lock * update Cargo.lock * fix wasm build error when use dependence git2 fix error link:https://dev.azure.com/nushell/nushell/_build/results?buildId=4858&view=logs&j=1a745d4c-b027-5f34-06d8-d6f256bfe9f9&t=a0a335cb-fa1f-5bbf-be01-1a90d6899e54 * remove code not used; fix warning by RUSTFLAGS="-D warnings" build error * upgrade shadow-rs 0.5.2 * upgrade shadow-rs 0.5.7 make nushell reduce dependence crates smaller and build fast. * upgrade shadow-rs 0.5.8 fix when use api 'strip_prefix()' method in less than rust1.45.0 build failed * use shadow-rs branch replace with current_branch method; remove and reduce git dependencies. * upgrade shadow-rs 0.5.12-pre,test build error with wasm * upgrade Cargo.lock * upgarde shadow-rs depencdence * fix build error in wasm * add clippy warning
This commit is contained in:
parent
f9b0b81eb2
commit
088e662285
6
Cargo.lock
generated
6
Cargo.lock
generated
@ -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",
|
||||
|
@ -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",
|
||||
|
@ -54,7 +54,6 @@ 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 }
|
||||
htmlescape = "0.3.1"
|
||||
@ -104,6 +103,7 @@ 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 }
|
||||
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"]
|
||||
|
@ -163,17 +163,9 @@ pub async fn cli(mut context: EvaluationContext) -> Result<(), Box<dyn Error>> {
|
||||
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<dyn Error>> {
|
||||
}
|
||||
}
|
||||
} 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<Strin
|
||||
result?.collect_string(Tag::unknown()).await.map(|x| x.item)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn current_branch() -> 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;
|
||||
|
@ -1,26 +0,0 @@
|
||||
pub fn current_branch() -> Option<String> {
|
||||
#[cfg(feature = "git2")]
|
||||
{
|
||||
use git2::{Repository, RepositoryOpenFlags};
|
||||
use std::ffi::OsString;
|
||||
|
||||
let v: Vec<OsString> = 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
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -53,7 +53,6 @@ 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 }
|
||||
htmlescape = "0.3.1"
|
||||
|
@ -165,11 +165,6 @@ fn features_enabled() -> Vec<String> {
|
||||
names.push("directories".to_string());
|
||||
}
|
||||
|
||||
#[cfg(feature = "git2")]
|
||||
{
|
||||
names.push("git".to_string());
|
||||
}
|
||||
|
||||
#[cfg(feature = "ptree")]
|
||||
{
|
||||
names.push("ptree".to_string());
|
||||
|
@ -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"
|
||||
|
1
tests/fixtures/formats/cargo_sample.toml
vendored
1
tests/fixtures/formats/cargo_sample.toml
vendored
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user