Commit 8fd3f40181

8fd3f40181a70a2490f1d96eaa9d716a9fadbdb8

parent: bf81b9d772

Unsigned

Sandro Santilli (AI assisted) <strk@kbt.io> · 2026-08-08 07:26 UTC

build: improve git describe handling

Re-run the build script when git state changes (HEAD, refs,
packed-refs) so the embedded GIT_DESCRIBE stays in sync with
branch switches, new commits and tags.

Print the git describe output as a Cargo warning on success so the
version string is visible during builds, and emit a warning when
git describe fails (e.g. building from a tarball without .git).

Assisted-By: MiniMax-M3 [via opencode 1.18.13]

Layout: unified · split

build.rs +6
@@ -7,6 +7,9 @@ enum WeechatApiVersions {
7 7
8fn main() { 8fn main() {
9 println!("cargo::rerun-if-changed=build.rs"); 9 println!("cargo::rerun-if-changed=build.rs");
10 println!("cargo::rerun-if-changed=.git/HEAD");
11 println!("cargo::rerun-if-changed=.git/refs");
12 println!("cargo::rerun-if-changed=.git/packed-refs");
10 println!("cargo::rerun-if-env-changed=WEECHAT_BUNDLED"); 13 println!("cargo::rerun-if-env-changed=WEECHAT_BUNDLED");
11 println!("cargo::rerun-if-env-changed=WEECHAT_PLUGIN_FILE"); 14 println!("cargo::rerun-if-env-changed=WEECHAT_PLUGIN_FILE");
12 println!("cargo::rustc-check-cfg=cfg(weechat410)"); 15 println!("cargo::rustc-check-cfg=cfg(weechat410)");
@@ -37,6 +40,9 @@ fn main() {
37 if output.status.success() { 40 if output.status.success() {
38 let describe = String::from_utf8_lossy(&output.stdout).trim().to_string(); 41 let describe = String::from_utf8_lossy(&output.stdout).trim().to_string();
39 println!("cargo::rustc-env=GIT_DESCRIBE={}", describe); 42 println!("cargo::rustc-env=GIT_DESCRIBE={}", describe);
43 println!("cargo::warning=weechat-matrix git describe: {}", describe);
44 } else {
45 println!("cargo::warning=weechat-matrix: git describe failed");
40 } 46 }
41 } 47 }
42} 48}