diff options
author | Jakob Borg <jakob@nym.se> | 2016-06-29 18:52:49 +0000 |
---|---|---|
committer | Audrius Butkevicius <audrius.butkevicius@gmail.com> | 2016-06-29 18:52:49 +0000 |
commit | 80fd6c2400868a24ffd104babd2ddf35c3ff9f0e (patch) | |
tree | b2d25acc0503ce2c330144cc67902d7c7ce122f7 | |
parent | 3cbe7d40d1d452c7b956d36a80febb3b3e03d090 (diff) |
build: Use SOURCE_DATE_EPOCH for build time stamp when available
Apparently common practice for reproducible builds:
https://reproducible-builds.org/specs/source-date-epoch/
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3364
-rw-r--r-- | build.go | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -717,10 +717,18 @@ func getBranchSuffix() string { } func buildStamp() int64 { + // If SOURCE_DATE_EPOCH is set, use that. + if s, _ := strconv.ParseInt(os.Getenv("SOURCE_DATE_EPOCH"), 10, 64); s > 0 { + return s + } + + // Try to get the timestamp of the latest commit. bs, err := runError("git", "show", "-s", "--format=%ct") if err != nil { + // Fall back to "now". return time.Now().Unix() } + s, _ := strconv.ParseInt(string(bs), 10, 64) return s } |