mirror of
https://github.com/SpaceManiac/SpacemanDMM.git
synced 2025-12-23 05:36:47 +00:00
23 lines
615 B
Rust
23 lines
615 B
Rust
extern crate chrono;
|
|
extern crate git2;
|
|
|
|
use std::io::Write;
|
|
use std::fs::File;
|
|
use std::env;
|
|
use std::path::PathBuf;
|
|
|
|
fn main() {
|
|
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
|
let mut f = File::create(&out_dir.join("build-info.txt")).unwrap();
|
|
|
|
if let Ok(commit) = read_commit() {
|
|
writeln!(f, "commit: {}", commit).unwrap();
|
|
}
|
|
writeln!(f, "build date: {}", chrono::Utc::today()).unwrap();
|
|
}
|
|
|
|
fn read_commit() -> Result<String, git2::Error> {
|
|
let repo = git2::Repository::discover(".")?;
|
|
let hash = repo.head()?.peel_to_commit()?.id().to_string();
|
|
Ok(hash)
|
|
}
|