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:
Darren Schroeder
2020-08-11 16:43:23 -05:00
committed by GitHub
parent cc3c10867c
commit 0194dee3a6
6 changed files with 28 additions and 52 deletions

View File

@@ -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(())
}