2 stable releases

1.1.0 Dec 23, 2022
1.0.0 Dec 22, 2022

#2145 in Procedural macros

Download history 5/week @ 2024-04-13 3/week @ 2024-04-20 1/week @ 2024-04-27 3/week @ 2024-05-04 6/week @ 2024-05-18 1/week @ 2024-05-25 4/week @ 2024-06-01 2/week @ 2024-06-08 12/week @ 2024-07-13 2/week @ 2024-07-20 37/week @ 2024-07-27

51 downloads per month

BSL-1.0 license

5KB
65 lines

Proc macro to access git repo properties at build time.

Usage

use git_const::{git_hash, git_short_hash, git_root};

const ROOT: &str = git_root!();
const SHORT_VERSION: &str = git_short_hash!();
const VERSION: &str = git_hash!();
assert_ne!(VERSION, "");
assert!(!VERSION.contains('\n'));
assert_ne!(VERSION, SHORT_VERSION);
assert!(VERSION.starts_with(SHORT_VERSION));

const MASTER_VERSION: &str = git_hash!(master);
assert_eq!(MASTER_VERSION, VERSION); //true if current branch is master
let path = std::path::Path::new(ROOT);
assert_eq!(path.file_name().unwrap().to_str().unwrap(), "git-const");

No runtime deps