Skip to content

Commit f568445

Browse files
Allow to override build date with SOURCE_DATE_EPOCH (#2202)
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. --------- Co-authored-by: extrawurst <[email protected]>
1 parent 3dca5fe commit f568445

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Diff for: CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
* respect configuration for remote when fetching (also applies to pulling) [[@cruessler](https://github.com/cruessler)] ([#1093](https://github.com/extrawurst/gitui/issues/1093))
1313
* add `:` character to sign-off trailer to comply with Conventinoal Commits standard [@semioticrobotic](https://github.com/semioticrobotic) ([#2196](https://github.com/extrawurst/gitui/issues/2196))
1414

15+
### Added
16+
* support overriding `build_date` for [reproducible builds](https://reproducible-builds.org/) [[@bmwiedemann](https://github.com/bmwiedemann)] ([#2202](https://github.com/extrawurst/gitui/pull/2202))
17+
1518
## [0.26.0+1] - 2024-04-14
1619

1720
**0.26.1**

Diff for: build.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use chrono::TimeZone;
2+
13
fn get_git_hash() -> String {
24
use std::process::Command;
35

@@ -18,7 +20,13 @@ fn get_git_hash() -> String {
1820
}
1921

2022
fn main() {
21-
let build_date = chrono::Local::now().date_naive();
23+
let now = match std::env::var("SOURCE_DATE_EPOCH") {
24+
Ok(val) => chrono::Local
25+
.timestamp_opt(val.parse::<i64>().unwrap(), 0)
26+
.unwrap(),
27+
Err(_) => chrono::Local::now(),
28+
};
29+
let build_date = now.date_naive();
2230

2331
let build_name = if std::env::var("GITUI_RELEASE").is_ok() {
2432
format!(

0 commit comments

Comments
 (0)