From fd9a0597d8c916a77f3b8ea511931df1a3a99d83 Mon Sep 17 00:00:00 2001 From: BlackDex Date: Wed, 6 Dec 2023 22:10:48 +0100 Subject: [PATCH] Check some `.git` paths to force a rebuild When a checked-out repo switches to a specific tag, and that tag does not have anything else changed in the files except the tag, it could happen that the build process doesn't see any changes, while it could be that the version string needs to be different. This commit ensures that if some specific paths are changed within the .git directory, cargo will be triggered to rebuild. Fixes #4087 --- build.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/build.rs b/build.rs index ac655e41..34ebec89 100644 --- a/build.rs +++ b/build.rs @@ -48,6 +48,11 @@ fn run(args: &[&str]) -> Result { /// - env!("GIT_REV") /// - env!("VW_VERSION") fn version_from_git_info() -> Result { + // Rerun when these paths are changed. + // Someone could have checked-out a tag or specific commit, but no other files changed. + println!("cargo:rerun-if-changed=.git/HEAD"); + println!("cargo:rerun-if-changed=.git/refs/tags/"); + // The exact tag for the current commit, can be empty when // the current commit doesn't have an associated tag let exact_tag = run(&["git", "describe", "--abbrev=0", "--tags", "--exact-match"]).ok();