summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLinus Färnstrand <faern@faern.net>2023-03-01 14:00:53 +0100
committerLinus Färnstrand <faern@faern.net>2023-03-01 14:00:53 +0100
commiteb350f03cbb223696b1ba534738b091f4b5e00cc (patch)
tree59cd6b6d838022472999c8d1b3459b816b5182af
parent5cf06297272ddfea513f76ae21ca8d2086176472 (diff)
downloadmullvadvpn-eb350f03cbb223696b1ba534738b091f4b5e00cc.tar.xz
mullvadvpn-eb350f03cbb223696b1ba534738b091f4b5e00cc.zip
Try less to be smart
-rw-r--r--mullvad-version/build.rs24
1 files changed, 7 insertions, 17 deletions
diff --git a/mullvad-version/build.rs b/mullvad-version/build.rs
index 9066d6178e..2e1ce9f3c1 100644
--- a/mullvad-version/build.rs
+++ b/mullvad-version/build.rs
@@ -92,29 +92,19 @@ fn get_dev_suffix(target: Target, product_version: &str) -> Option<String> {
/// Returns `None` if executing the `git rev-parse` command fails for some reason.
fn git_rev_parse_commit_hash(git_ref: &str) -> Option<String> {
let git_dir = Path::new("..").join(".git");
+ // If we build our output on information about HEAD we need to re-run if HEAD moves
if git_ref == "HEAD" {
- // If we build our output on information about HEAD we need to re-run if HEAD moves
let head_path = git_dir.join("HEAD");
if head_path.exists() {
println!("cargo:rerun-if-changed={}", head_path.display());
-
- // If HEAD points to a reference, we want to re-run if that reference moves
- let head_content = fs::read_to_string(head_path).unwrap();
- if let Some(ref_name) = head_content.strip_prefix("ref: ") {
- let ref_path = git_dir.join(ref_name);
- println!("cargo:rerun-if-changed={}", ref_path.display());
- }
- }
- } else {
- // If we build our output on information about a git reference, we need to re-run
- // if it moves. We don't know if the ref is a head, remote or tag, so we check all.
- for ref_type in ["heads", "remotes", "tags"] {
- let ref_path = git_dir.join("refs").join(ref_type).join(git_ref);
- if ref_path.exists() {
- println!("cargo:rerun-if-changed={}", ref_path.display());
- }
}
}
+ // If we build our output on information about a git reference, we need to re-run
+ // if it moves. Instead of trying to be smart, just re-run if any git reference moves.
+ let git_refs_dir = git_dir.join("refs");
+ if git_refs_dir.exists() {
+ println!("cargo:rerun-if-changed={}", git_refs_dir.display());
+ }
let output = Command::new("git")
.arg("rev-parse")