mirror of
https://github.com/watchexec/watchexec.git
synced 2024-11-14 00:01:12 +01:00
feat: Add git-describe support (#832)
This commit is contained in:
parent
72f069a847
commit
2026c52abd
6 changed files with 161 additions and 7 deletions
37
Cargo.lock
generated
37
Cargo.lock
generated
|
@ -1317,6 +1317,7 @@ dependencies = [
|
||||||
"gix-glob",
|
"gix-glob",
|
||||||
"gix-hash",
|
"gix-hash",
|
||||||
"gix-hashtable",
|
"gix-hashtable",
|
||||||
|
"gix-index",
|
||||||
"gix-lock",
|
"gix-lock",
|
||||||
"gix-macros",
|
"gix-macros",
|
||||||
"gix-object",
|
"gix-object",
|
||||||
|
@ -1354,6 +1355,15 @@ dependencies = [
|
||||||
"winnow 0.6.6",
|
"winnow 0.6.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gix-bitmap"
|
||||||
|
version = "0.2.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a371db66cbd4e13f0ed9dc4c0fea712d7276805fccc877f77e96374d317e87ae"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gix-chunk"
|
name = "gix-chunk"
|
||||||
version = "0.4.8"
|
version = "0.4.8"
|
||||||
|
@ -1513,6 +1523,33 @@ dependencies = [
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gix-index"
|
||||||
|
version = "0.32.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "881ab3b1fa57f497601a5add8289e72a7ae09471fc0b9bbe483b628ae8e418a1"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.5.0",
|
||||||
|
"bstr",
|
||||||
|
"filetime",
|
||||||
|
"fnv",
|
||||||
|
"gix-bitmap",
|
||||||
|
"gix-features",
|
||||||
|
"gix-fs",
|
||||||
|
"gix-hash",
|
||||||
|
"gix-lock",
|
||||||
|
"gix-object",
|
||||||
|
"gix-traverse",
|
||||||
|
"gix-utils",
|
||||||
|
"hashbrown 0.14.3",
|
||||||
|
"itoa",
|
||||||
|
"libc",
|
||||||
|
"memmap2",
|
||||||
|
"rustix",
|
||||||
|
"smallvec",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gix-lock"
|
name = "gix-lock"
|
||||||
version = "13.1.1"
|
version = "13.1.1"
|
||||||
|
|
|
@ -22,6 +22,7 @@ features = ["macros", "formatting"]
|
||||||
version = "0.62.0"
|
version = "0.62.0"
|
||||||
optional = true
|
optional = true
|
||||||
default-features = false
|
default-features = false
|
||||||
|
features = ["revision"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["git", "reproducible", "std"]
|
default = ["git", "reproducible", "std"]
|
||||||
|
|
105
crates/bosion/examples/clap/Cargo.lock
generated
105
crates/bosion/examples/clap/Cargo.lock
generated
|
@ -8,6 +8,24 @@ version = "1.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ahash"
|
||||||
|
version = "0.8.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"once_cell",
|
||||||
|
"version_check",
|
||||||
|
"zerocopy",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "allocator-api2"
|
||||||
|
version = "0.2.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstream"
|
name = "anstream"
|
||||||
version = "0.6.13"
|
version = "0.6.13"
|
||||||
|
@ -82,7 +100,7 @@ checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bosion"
|
name = "bosion"
|
||||||
version = "1.0.2"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gix",
|
"gix",
|
||||||
"time",
|
"time",
|
||||||
|
@ -211,6 +229,18 @@ version = "2.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984"
|
checksum = "658bd65b1cf4c852a3cc96f18a8ce7b5640f6b703f905c7d74532294c2a63984"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "filetime"
|
||||||
|
version = "0.2.23"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1ee447700ac8aa0b2f2bd7bc4462ad686ba06baa6727ac149a2d6277f0d240fd"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"redox_syscall",
|
||||||
|
"windows-sys",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.28"
|
version = "1.0.28"
|
||||||
|
@ -221,6 +251,12 @@ dependencies = [
|
||||||
"miniz_oxide",
|
"miniz_oxide",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "fnv"
|
||||||
|
version = "1.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "form_urlencoded"
|
name = "form_urlencoded"
|
||||||
version = "1.2.1"
|
version = "1.2.1"
|
||||||
|
@ -247,6 +283,7 @@ dependencies = [
|
||||||
"gix-glob",
|
"gix-glob",
|
||||||
"gix-hash",
|
"gix-hash",
|
||||||
"gix-hashtable",
|
"gix-hashtable",
|
||||||
|
"gix-index",
|
||||||
"gix-lock",
|
"gix-lock",
|
||||||
"gix-macros",
|
"gix-macros",
|
||||||
"gix-object",
|
"gix-object",
|
||||||
|
@ -284,6 +321,15 @@ dependencies = [
|
||||||
"winnow",
|
"winnow",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gix-bitmap"
|
||||||
|
version = "0.2.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a371db66cbd4e13f0ed9dc4c0fea712d7276805fccc877f77e96374d317e87ae"
|
||||||
|
dependencies = [
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gix-chunk"
|
name = "gix-chunk"
|
||||||
version = "0.4.8"
|
version = "0.4.8"
|
||||||
|
@ -443,6 +489,33 @@ dependencies = [
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gix-index"
|
||||||
|
version = "0.32.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "881ab3b1fa57f497601a5add8289e72a7ae09471fc0b9bbe483b628ae8e418a1"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.5.0",
|
||||||
|
"bstr",
|
||||||
|
"filetime",
|
||||||
|
"fnv",
|
||||||
|
"gix-bitmap",
|
||||||
|
"gix-features",
|
||||||
|
"gix-fs",
|
||||||
|
"gix-hash",
|
||||||
|
"gix-lock",
|
||||||
|
"gix-object",
|
||||||
|
"gix-traverse",
|
||||||
|
"gix-utils",
|
||||||
|
"hashbrown",
|
||||||
|
"itoa",
|
||||||
|
"libc",
|
||||||
|
"memmap2",
|
||||||
|
"rustix",
|
||||||
|
"smallvec",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gix-lock"
|
name = "gix-lock"
|
||||||
version = "13.1.1"
|
version = "13.1.1"
|
||||||
|
@ -702,6 +775,10 @@ name = "hashbrown"
|
||||||
version = "0.14.3"
|
version = "0.14.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
|
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
|
||||||
|
dependencies = [
|
||||||
|
"ahash",
|
||||||
|
"allocator-api2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
|
@ -1076,6 +1153,12 @@ version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "version_check"
|
||||||
|
version = "0.9.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "walkdir"
|
name = "walkdir"
|
||||||
version = "2.5.0"
|
version = "2.5.0"
|
||||||
|
@ -1255,3 +1338,23 @@ checksum = "f0c976aaaa0e1f90dbb21e9587cdaf1d9679a1cde8875c0d6bd83ab96a208352"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.7.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ae87e3fcd617500e5d106f0380cf7b77f3c6092aae37191433159dda23cfb087"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.7.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
|
@ -13,6 +13,9 @@ struct Args {
|
||||||
|
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
dates: bool,
|
dates: bool,
|
||||||
|
|
||||||
|
#[clap(long)]
|
||||||
|
describe: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -23,17 +26,15 @@ fn main() {
|
||||||
"{}",
|
"{}",
|
||||||
Bosion::long_version_with(&[("extra", "field"), ("custom", "1.2.3"),])
|
Bosion::long_version_with(&[("extra", "field"), ("custom", "1.2.3"),])
|
||||||
);
|
);
|
||||||
} else
|
} else if args.features {
|
||||||
|
|
||||||
if args.features {
|
|
||||||
println!("Features: {}", Bosion::CRATE_FEATURE_STRING);
|
println!("Features: {}", Bosion::CRATE_FEATURE_STRING);
|
||||||
} else
|
} else if args.dates {
|
||||||
|
|
||||||
if args.dates {
|
|
||||||
println!("commit date: {}", Bosion::GIT_COMMIT_DATE);
|
println!("commit date: {}", Bosion::GIT_COMMIT_DATE);
|
||||||
println!("commit datetime: {}", Bosion::GIT_COMMIT_DATETIME);
|
println!("commit datetime: {}", Bosion::GIT_COMMIT_DATETIME);
|
||||||
println!("build date: {}", Bosion::BUILD_DATE);
|
println!("build date: {}", Bosion::BUILD_DATE);
|
||||||
println!("build datetime: {}", Bosion::BUILD_DATETIME);
|
println!("build datetime: {}", Bosion::BUILD_DATETIME);
|
||||||
|
} else if args.describe {
|
||||||
|
println!("commit description: {}", Bosion::GIT_COMMIT_DESCRIPTION);
|
||||||
} else {
|
} else {
|
||||||
println!("{}", Bosion::LONG_VERSION);
|
println!("{}", Bosion::LONG_VERSION);
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,6 +145,9 @@ pub struct GitInfo {
|
||||||
|
|
||||||
/// The datetime of the current commit, in the format `YYYY-MM-DD HH:MM:SS`, at UTC.
|
/// The datetime of the current commit, in the format `YYYY-MM-DD HH:MM:SS`, at UTC.
|
||||||
pub git_datetime: String,
|
pub git_datetime: String,
|
||||||
|
|
||||||
|
/// The `git describe` equivalent output
|
||||||
|
pub git_description: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "git")]
|
#[cfg(feature = "git")]
|
||||||
|
@ -163,6 +166,7 @@ impl GitInfo {
|
||||||
git_shorthash: head.short_id().err_string()?.to_string(),
|
git_shorthash: head.short_id().err_string()?.to_string(),
|
||||||
git_date: timestamp.format(DATE_FORMAT).err_string()?,
|
git_date: timestamp.format(DATE_FORMAT).err_string()?,
|
||||||
git_datetime: timestamp.format(DATETIME_FORMAT).err_string()?,
|
git_datetime: timestamp.format(DATETIME_FORMAT).err_string()?,
|
||||||
|
git_description: head.describe().format().err_string()?.to_string(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,6 +74,7 @@ pub fn gather_to(filename: &str, structname: &str, public: bool) {
|
||||||
git_shorthash,
|
git_shorthash,
|
||||||
git_date,
|
git_date,
|
||||||
git_datetime,
|
git_datetime,
|
||||||
|
git_description,
|
||||||
..
|
..
|
||||||
}) = git
|
}) = git
|
||||||
{
|
{
|
||||||
|
@ -104,6 +105,11 @@ pub fn gather_to(filename: &str, structname: &str, public: bool) {
|
||||||
/// This is the date and time (`YYYY-MM-DD HH:MM:SS`) of the commit that was built. Same
|
/// This is the date and time (`YYYY-MM-DD HH:MM:SS`) of the commit that was built. Same
|
||||||
/// caveats as with `GIT_COMMIT_HASH` apply.
|
/// caveats as with `GIT_COMMIT_HASH` apply.
|
||||||
pub const GIT_COMMIT_DATETIME: &'static str = {git_datetime:?};
|
pub const GIT_COMMIT_DATETIME: &'static str = {git_datetime:?};
|
||||||
|
|
||||||
|
/// The git description
|
||||||
|
///
|
||||||
|
/// This is the string equivalent to what `git describe` would output
|
||||||
|
pub const GIT_COMMIT_DESCRIPTION: &'static str = {git_description:?};
|
||||||
"
|
"
|
||||||
), format!("{crate_version} ({git_shorthash} {git_date}) {crate_feature_string}\ncommit-hash: {git_hash}\ncommit-date: {git_date}\nbuild-date: {build_date}\nrelease: {crate_version}\nfeatures: {crate_feature_list}"))
|
), format!("{crate_version} ({git_shorthash} {git_date}) {crate_feature_string}\ncommit-hash: {git_hash}\ncommit-date: {git_date}\nbuild-date: {build_date}\nrelease: {crate_version}\nfeatures: {crate_feature_list}"))
|
||||||
} else {
|
} else {
|
||||||
|
@ -244,6 +250,7 @@ pub fn gather_to_env_with_prefix(prefix: &str) {
|
||||||
git_shorthash,
|
git_shorthash,
|
||||||
git_date,
|
git_date,
|
||||||
git_datetime,
|
git_datetime,
|
||||||
|
git_description,
|
||||||
..
|
..
|
||||||
}) = git
|
}) = git
|
||||||
{
|
{
|
||||||
|
@ -251,5 +258,6 @@ pub fn gather_to_env_with_prefix(prefix: &str) {
|
||||||
println!("cargo:rustc-env={prefix}GIT_COMMIT_SHORTHASH={git_shorthash}");
|
println!("cargo:rustc-env={prefix}GIT_COMMIT_SHORTHASH={git_shorthash}");
|
||||||
println!("cargo:rustc-env={prefix}GIT_COMMIT_DATE={git_date}");
|
println!("cargo:rustc-env={prefix}GIT_COMMIT_DATE={git_date}");
|
||||||
println!("cargo:rustc-env={prefix}GIT_COMMIT_DATETIME={git_datetime}");
|
println!("cargo:rustc-env={prefix}GIT_COMMIT_DATETIME={git_datetime}");
|
||||||
|
println!("cargo:rustc-env={prefix}GIT_COMMIT_DESCRIPTION={git_description}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue