From 53cdd8a5b127c852b77444fe3ad66be9be39738d Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 15 Apr 2024 13:59:41 +0300 Subject: [PATCH] Allow builds from 'git archive' generated tarballs --- CHANGELOG.md | 3 +++ build.rs | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 271cfcfe16..6214245135 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added +* enable builds from `git archive` generated source tarballs [[@alerque](https://github.com/alerque)] ([#2187](https://github.com/extrawurst/gitui/pull/2187)) + ## [0.26.0+1] - 2024-04-14 **0.26.1** diff --git a/build.rs b/build.rs index 64470c19f4..ebbfc65b62 100644 --- a/build.rs +++ b/build.rs @@ -1,9 +1,14 @@ fn get_git_hash() -> String { use std::process::Command; + // Allow builds from `git archive` generated tarballs if output of `git get-tar-commit-id` is + // set in an env var. + if let Ok(commit) = std::env::var("TAR_COMMIT_ID") { + return commit[..7].to_string(); + }; let commit = Command::new("git") .arg("rev-parse") - .arg("--short") + .arg("--short=7") .arg("--verify") .arg("HEAD") .output();