From 4416e16446fd97c7835e2a4ac2268724ccb02870 Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Wed, 24 Apr 2024 04:56:31 +0200 Subject: [PATCH 1/3] Allow to override build date with SOURCE_DATE_EPOCH to make builds reproducible. See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. This patch was done while working on reproducible builds for openSUSE. --- CHANGELOG.md | 2 ++ build.rs | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 271cfcfe16..3d81791e60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +* support overriding `build_date` for [reproducible builds](https://reproducible-builds.org/) [[@bmwiedemann](https://github.com/bmwiedemann)] ([#2202](https://github.com/extrawurst/gitui/pull/2202)) + ## [0.26.0+1] - 2024-04-14 **0.26.1** diff --git a/build.rs b/build.rs index 64470c19f4..4b207b03d0 100644 --- a/build.rs +++ b/build.rs @@ -1,3 +1,5 @@ +use chrono::TimeZone; + fn get_git_hash() -> String { use std::process::Command; @@ -18,7 +20,11 @@ fn get_git_hash() -> String { } fn main() { - let build_date = chrono::Local::now().date_naive(); + let now = match std::env::var("SOURCE_DATE_EPOCH") { + Ok(val) => { chrono::Local.timestamp_opt(val.parse::().unwrap(), 0).unwrap() } + Err(_) => chrono::Local::now(), + }; + let build_date = now.date_naive(); let build_name = if std::env::var("GITUI_RELEASE").is_ok() { format!( From 81bd7447dd73d5beab1353308b7b304f64e79a15 Mon Sep 17 00:00:00 2001 From: extrawurst Date: Thu, 16 May 2024 17:04:17 +0200 Subject: [PATCH 2/3] cargo fmt --- build.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 4b207b03d0..e217973c3f 100644 --- a/build.rs +++ b/build.rs @@ -21,7 +21,9 @@ fn get_git_hash() -> String { fn main() { let now = match std::env::var("SOURCE_DATE_EPOCH") { - Ok(val) => { chrono::Local.timestamp_opt(val.parse::().unwrap(), 0).unwrap() } + Ok(val) => chrono::Local + .timestamp_opt(val.parse::().unwrap(), 0) + .unwrap(), Err(_) => chrono::Local::now(), }; let build_date = now.date_naive(); From 78f17b05e9deb3a5d647a0f5b148397b72a5a0bd Mon Sep 17 00:00:00 2001 From: extrawurst Date: Thu, 16 May 2024 17:05:57 +0200 Subject: [PATCH 3/3] add changelog category --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d81791e60..e6f8d149a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added * support overriding `build_date` for [reproducible builds](https://reproducible-builds.org/) [[@bmwiedemann](https://github.com/bmwiedemann)] ([#2202](https://github.com/extrawurst/gitui/pull/2202)) ## [0.26.0+1] - 2024-04-14 -**0.26.1** +**0.26.1** this release has no changes to `0.26.0` but provides windows binaries that were missing before. **commit signing**