2 stable releases

1.1.0 Dec 23, 2022
1.0.0 Dec 22, 2022

#2036 in Procedural macros

Download history 20/week @ 2024-01-01 56/week @ 2024-01-08 6/week @ 2024-01-15 14/week @ 2024-01-29 5/week @ 2024-02-05 10/week @ 2024-02-19 23/week @ 2024-02-26 7/week @ 2024-03-11 7/week @ 2024-03-18 14/week @ 2024-03-25 63/week @ 2024-04-01

91 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