From 166d1811a182bc30a505c14f9dde64ffd78ff299 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Mon, 19 Dec 2016 21:14:12 +0100 Subject: [PATCH] Remove timestamp from `version` command This enables reproducible builds, for details see https://reproducible-builds.org/docs/timestamps/ --- build.go | 6 +----- src/cmds/restic/cmd_version.go | 4 ++-- src/cmds/restic/global.go | 1 - 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/build.go b/build.go index 04a65d182..8406492d6 100644 --- a/build.go +++ b/build.go @@ -12,7 +12,6 @@ import ( "path/filepath" "runtime" "strings" - "time" ) var ( @@ -33,8 +32,6 @@ var config = struct { Tests: []string{"restic/...", "cmds/..."}, // tests to run } -const timeFormat = "2006-01-02 15:04:05" - // specialDir returns true if the file begins with a special character ('.' or '_'). func specialDir(name string) bool { if name == "." { @@ -392,8 +389,7 @@ func main() { output := filepath.Join(cwd, outputFilename) version := getVersion() - compileTime := time.Now().Format(timeFormat) - constants := Constants{`main.compiledAt`: compileTime} + constants := Constants{} if version != "" { constants["main.version"] = version } diff --git a/src/cmds/restic/cmd_version.go b/src/cmds/restic/cmd_version.go index 1bc7b9925..9290af0a3 100644 --- a/src/cmds/restic/cmd_version.go +++ b/src/cmds/restic/cmd_version.go @@ -15,8 +15,8 @@ The "version" command prints detailed information about the build environment and the version of this software. `, Run: func(cmd *cobra.Command, args []string) { - fmt.Printf("restic %s\ncompiled at %s with %v on %v/%v\n", - version, compiledAt, runtime.Version(), runtime.GOOS, runtime.GOARCH) + fmt.Printf("restic %s\ncompiled with %v on %v/%v\n", + version, runtime.Version(), runtime.GOOS, runtime.GOARCH) }, } diff --git a/src/cmds/restic/global.go b/src/cmds/restic/global.go index b4e172d4a..c2f915ac3 100644 --- a/src/cmds/restic/global.go +++ b/src/cmds/restic/global.go @@ -26,7 +26,6 @@ import ( ) var version = "compiled manually" -var compiledAt = "unknown time" func parseEnvironment(cmd *cobra.Command, args []string) { repo := os.Getenv("RESTIC_REPOSITORY")