mirror of
https://github.com/nushell/nushell.git
synced 2024-11-29 11:54:02 +01:00
Updated version hashing and bumped nu-cli to 0.18.1 (#2331)
* Updated version hashing and bumped nu-cli to 0.18.1 * made code pertyer * Update version.rs * Update version.rs Co-authored-by: Jonathan Turner <jonathandturner@users.noreply.github.com>
This commit is contained in:
parent
cc3c10867c
commit
0194dee3a6
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -2095,6 +2095,15 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "last-git-commit"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9f2e5243385b2ea0443d79fd6f5ea97b0509f2571e8f39e99d1ead2bcc1c89c0"
|
||||||
|
dependencies = [
|
||||||
|
"git2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lazy_static"
|
name = "lazy_static"
|
||||||
version = "0.2.11"
|
version = "0.2.11"
|
||||||
@ -2627,7 +2636,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nu-cli"
|
name = "nu-cli"
|
||||||
version = "0.18.0"
|
version = "0.18.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"ansi_term 0.12.1",
|
"ansi_term 0.12.1",
|
||||||
"app_dirs2",
|
"app_dirs2",
|
||||||
@ -2664,6 +2673,7 @@ dependencies = [
|
|||||||
"ichwh",
|
"ichwh",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itertools",
|
"itertools",
|
||||||
|
"last-git-commit",
|
||||||
"log",
|
"log",
|
||||||
"meval",
|
"meval",
|
||||||
"natural",
|
"natural",
|
||||||
|
@ -18,7 +18,7 @@ members = ["crates/*/"]
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-cli = {version = "0.18.0", path = "./crates/nu-cli"}
|
nu-cli = {version = "0.18.1", path = "./crates/nu-cli"}
|
||||||
nu-errors = {version = "0.18.0", path = "./crates/nu-errors"}
|
nu-errors = {version = "0.18.0", path = "./crates/nu-errors"}
|
||||||
nu-parser = {version = "0.18.0", path = "./crates/nu-parser"}
|
nu-parser = {version = "0.18.0", path = "./crates/nu-parser"}
|
||||||
nu-plugin = {version = "0.18.0", path = "./crates/nu-plugin"}
|
nu-plugin = {version = "0.18.0", path = "./crates/nu-plugin"}
|
||||||
|
@ -4,7 +4,7 @@ description = "CLI for nushell"
|
|||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
name = "nu-cli"
|
name = "nu-cli"
|
||||||
version = "0.18.0"
|
version = "0.18.1"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
doctest = false
|
doctest = false
|
||||||
@ -52,6 +52,7 @@ ical = "0.6.*"
|
|||||||
ichwh = {version = "0.3.4", optional = true}
|
ichwh = {version = "0.3.4", optional = true}
|
||||||
indexmap = {version = "1.4.0", features = ["serde-1"]}
|
indexmap = {version = "1.4.0", features = ["serde-1"]}
|
||||||
itertools = "0.9.0"
|
itertools = "0.9.0"
|
||||||
|
last-git-commit = "0.2.0"
|
||||||
log = "0.4.8"
|
log = "0.4.8"
|
||||||
meval = "0.2"
|
meval = "0.2"
|
||||||
natural = "0.5.0"
|
natural = "0.5.0"
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
use std::path::Path;
|
|
||||||
use std::{env, fs, io};
|
|
||||||
|
|
||||||
use git2::Repository;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
enum Error {
|
|
||||||
IoError(io::Error),
|
|
||||||
GitError(git2::Error),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<git2::Error> for Error {
|
|
||||||
fn from(git_error: git2::Error) -> Self {
|
|
||||||
Self::GitError(git_error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<io::Error> for Error {
|
|
||||||
fn from(io_error: io::Error) -> Self {
|
|
||||||
Self::IoError(io_error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() -> Result<(), Error> {
|
|
||||||
let out_dir = env::var_os("OUT_DIR").expect(
|
|
||||||
"\
|
|
||||||
OUT_DIR environment variable not found. \
|
|
||||||
OUT_DIR is guaranteed to to exist in a build script by cargo - see \
|
|
||||||
https://doc.rust-lang.org/cargo/reference/environment-variables.html#environment-variables-cargo-sets-for-build-scripts\
|
|
||||||
");
|
|
||||||
let latest_commit_hash = Repository::discover(env::current_dir()?)?
|
|
||||||
.head()?
|
|
||||||
.peel_to_commit()?
|
|
||||||
.id()
|
|
||||||
.to_string();
|
|
||||||
|
|
||||||
let commit_hash_path = Path::new(&out_dir).join("git_commit_hash");
|
|
||||||
fs::write(commit_hash_path, latest_commit_hash)?;
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
@ -1,11 +1,10 @@
|
|||||||
use crate::commands::WholeStreamCommand;
|
use crate::commands::WholeStreamCommand;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
|
use last_git_commit::LastGitCommit;
|
||||||
use nu_errors::ShellError;
|
use nu_errors::ShellError;
|
||||||
use nu_protocol::{Dictionary, Signature, UntaggedValue};
|
use nu_protocol::{Dictionary, Signature, UntaggedValue};
|
||||||
|
|
||||||
const GIT_COMMIT_HASH: &str = include_str!(concat!(env!("OUT_DIR"), "/git_commit_hash"));
|
|
||||||
|
|
||||||
pub struct Version;
|
pub struct Version;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@ -42,16 +41,23 @@ impl WholeStreamCommand for Version {
|
|||||||
pub fn version(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
pub fn version(args: CommandArgs, _registry: &CommandRegistry) -> Result<OutputStream, ShellError> {
|
||||||
let tag = args.call_info.args.span;
|
let tag = args.call_info.args.span;
|
||||||
|
|
||||||
let mut indexmap = IndexMap::with_capacity(2);
|
let mut indexmap = IndexMap::with_capacity(3);
|
||||||
|
|
||||||
indexmap.insert(
|
indexmap.insert(
|
||||||
"version".to_string(),
|
"version".to_string(),
|
||||||
UntaggedValue::string(clap::crate_version!()).into_value(&tag),
|
UntaggedValue::string(clap::crate_version!()).into_value(&tag),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if let Ok(lgc) = LastGitCommit::new().build() {
|
||||||
indexmap.insert(
|
indexmap.insert(
|
||||||
"commit_hash".to_string(),
|
"short_commit_hash".to_string(),
|
||||||
UntaggedValue::string(GIT_COMMIT_HASH).into_value(&tag),
|
UntaggedValue::string(lgc.id().short()).into_value(&tag),
|
||||||
);
|
);
|
||||||
|
indexmap.insert(
|
||||||
|
"long_commit_hash".to_string(),
|
||||||
|
UntaggedValue::string(lgc.id().long()).into_value(&tag),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let value = UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&tag);
|
let value = UntaggedValue::Row(Dictionary::from(indexmap)).into_value(&tag);
|
||||||
Ok(OutputStream::one(value))
|
Ok(OutputStream::one(value))
|
||||||
|
@ -10,7 +10,7 @@ version = "0.18.0"
|
|||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
nu-cli = {path = "../nu-cli", version = "0.18.0"}
|
nu-cli = {path = "../nu-cli", version = "0.18.1"}
|
||||||
nu-errors = {path = "../nu-errors", version = "0.18.0"}
|
nu-errors = {path = "../nu-errors", version = "0.18.0"}
|
||||||
nu-plugin = {path = "../nu-plugin", version = "0.18.0"}
|
nu-plugin = {path = "../nu-plugin", version = "0.18.0"}
|
||||||
nu-protocol = {path = "../nu-protocol", version = "0.18.0"}
|
nu-protocol = {path = "../nu-protocol", version = "0.18.0"}
|
||||||
|
Loading…
Reference in New Issue
Block a user