mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
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
This commit is contained in:
parent
3cbe7d40d1
commit
80fd6c2400
8
build.go
8
build.go
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user