forked from extern/nushell
Look up git commit hash ourselves, drop libgit2 dependency (#5548)
This commit is contained in:
parent
44bcfb3403
commit
d90b25c633
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4191,7 +4191,6 @@ checksum = "f47e98e36909e951f4da3908f4475f969bec92a41734dd92e883aaa11c10294b"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"const_format",
|
"const_format",
|
||||||
"git2",
|
|
||||||
"is_debug",
|
"is_debug",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -70,7 +70,8 @@ serde_ini = "0.2.0"
|
|||||||
serde_urlencoded = "0.7.0"
|
serde_urlencoded = "0.7.0"
|
||||||
serde_yaml = "0.8.16"
|
serde_yaml = "0.8.16"
|
||||||
sha2 = "0.10.0"
|
sha2 = "0.10.0"
|
||||||
shadow-rs = "0.11.0"
|
# Disable default features b/c the default features build Git (very slow to compile)
|
||||||
|
shadow-rs = { version = "0.11.0", default-features = false }
|
||||||
strip-ansi-escapes = "0.1.1"
|
strip-ansi-escapes = "0.1.1"
|
||||||
sysinfo = "0.23.5"
|
sysinfo = "0.23.5"
|
||||||
terminal_size = "0.1.17"
|
terminal_size = "0.1.17"
|
||||||
@ -112,7 +113,7 @@ dataframe = ["polars", "num"]
|
|||||||
database = ["sqlparser", "rusqlite"]
|
database = ["sqlparser", "rusqlite"]
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
shadow-rs = "0.11.0"
|
shadow-rs = { version = "0.11.0", default-features = false }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
hamcrest2 = "0.3.0"
|
hamcrest2 = "0.3.0"
|
||||||
|
@ -1,3 +1,18 @@
|
|||||||
|
use std::process::Command;
|
||||||
|
|
||||||
fn main() -> shadow_rs::SdResult<()> {
|
fn main() -> shadow_rs::SdResult<()> {
|
||||||
|
// Look up the current Git commit ourselves instead of relying on shadow_rs,
|
||||||
|
// because shadow_rs does it in a really slow-to-compile way (it builds libgit2)
|
||||||
|
let hash = get_git_hash().expect("failed to get latest git commit hash");
|
||||||
|
println!("cargo:rustc-env=NU_COMMIT_HASH={}", hash);
|
||||||
|
|
||||||
shadow_rs::new()
|
shadow_rs::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_git_hash() -> Result<String, std::io::Error> {
|
||||||
|
let out = Command::new("git").args(["rev-parse", "HEAD"]).output()?;
|
||||||
|
Ok(String::from_utf8(out.stdout)
|
||||||
|
.expect("could not convert stdout to string")
|
||||||
|
.trim()
|
||||||
|
.to_string())
|
||||||
|
}
|
||||||
|
@ -63,21 +63,7 @@ pub fn version(
|
|||||||
span: call.head,
|
span: call.head,
|
||||||
});
|
});
|
||||||
|
|
||||||
cols.push("tag".to_string());
|
let commit_hash: Option<&str> = option_env!("NU_COMMIT_HASH");
|
||||||
vals.push(Value::String {
|
|
||||||
val: shadow_rs::tag(),
|
|
||||||
span: call.head,
|
|
||||||
});
|
|
||||||
|
|
||||||
let short_commit: Option<&str> = Some(shadow::SHORT_COMMIT).filter(|x| !x.is_empty());
|
|
||||||
if let Some(short_commit) = short_commit {
|
|
||||||
cols.push("short_commit".to_string());
|
|
||||||
vals.push(Value::String {
|
|
||||||
val: short_commit.to_string(),
|
|
||||||
span: call.head,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
let commit_hash: Option<&str> = Some(shadow::COMMIT_HASH).filter(|x| !x.is_empty());
|
|
||||||
if let Some(commit_hash) = commit_hash {
|
if let Some(commit_hash) = commit_hash {
|
||||||
cols.push("commit_hash".to_string());
|
cols.push("commit_hash".to_string());
|
||||||
vals.push(Value::String {
|
vals.push(Value::String {
|
||||||
@ -85,14 +71,6 @@ pub fn version(
|
|||||||
span: call.head,
|
span: call.head,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
let commit_date: Option<&str> = Some(shadow::COMMIT_DATE).filter(|x| !x.is_empty());
|
|
||||||
if let Some(commit_date) = commit_date {
|
|
||||||
cols.push("commit_date".to_string());
|
|
||||||
vals.push(Value::String {
|
|
||||||
val: commit_date.to_string(),
|
|
||||||
span: call.head,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let build_os: Option<&str> = Some(shadow::BUILD_OS).filter(|x| !x.is_empty());
|
let build_os: Option<&str> = Some(shadow::BUILD_OS).filter(|x| !x.is_empty());
|
||||||
if let Some(build_os) = build_os {
|
if let Some(build_os) = build_os {
|
||||||
|
Loading…
Reference in New Issue
Block a user