Skip to content

Commit 13d53b3

Browse files
committed
commands: Remove superflous BuildDate logic
Fixes #4272
1 parent 51dd462 commit 13d53b3

File tree

3 files changed

+1
-49
lines changed

3 files changed

+1
-49
lines changed

‎Gopkg.lock‎

Lines changed: 1 addition & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Gopkg.toml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@
5252
name = "github.com/jdkato/prose"
5353
version = "1.1.0"
5454

55-
[[constraint]]
56-
branch = "master"
57-
name = "github.com/kardianos/osext"
58-
5955
[[constraint]]
6056
name = "github.com/kyokomi/emoji"
6157
version = "1.5.0"

‎commands/version.go‎

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,11 @@
1414
package commands
1515

1616
import (
17-
"os"
18-
"path/filepath"
1917
"runtime"
2018
"strings"
21-
"time"
2219

2320
"github.com/gohugoio/hugo/helpers"
2421
"github.com/gohugoio/hugo/hugolib"
25-
"github.com/kardianos/osext"
2622
"github.com/spf13/cobra"
2723
jww "github.com/spf13/jwalterweatherman"
2824
)
@@ -38,43 +34,9 @@ var versionCmd = &cobra.Command{
3834
}
3935

4036
func printHugoVersion() {
41-
if hugolib.BuildDate == "" {
42-
setBuildDate() // set the build date from executable's mdate
43-
} else {
44-
formatBuildDate() // format the compile time
45-
}
4637
if hugolib.CommitHash == "" {
4738
jww.FEEDBACK.Printf("Hugo Static Site Generator v%s %s/%s BuildDate: %s\n", helpers.CurrentHugoVersion, runtime.GOOS, runtime.GOARCH, hugolib.BuildDate)
4839
} else {
4940
jww.FEEDBACK.Printf("Hugo Static Site Generator v%s-%s %s/%s BuildDate: %s\n", helpers.CurrentHugoVersion, strings.ToUpper(hugolib.CommitHash), runtime.GOOS, runtime.GOARCH, hugolib.BuildDate)
5041
}
5142
}
52-
53-
// setBuildDate checks the ModTime of the Hugo executable and returns it as a
54-
// formatted string. This assumes that the executable name is Hugo, if it does
55-
// not exist, an empty string will be returned. This is only called if the
56-
// hugolib.BuildDate wasn't set during compile time.
57-
//
58-
// osext is used for cross-platform.
59-
func setBuildDate() {
60-
fname, _ := osext.Executable()
61-
dir, err := filepath.Abs(filepath.Dir(fname))
62-
if err != nil {
63-
jww.ERROR.Println(err)
64-
return
65-
}
66-
fi, err := os.Lstat(filepath.Join(dir, filepath.Base(fname)))
67-
if err != nil {
68-
jww.ERROR.Println(err)
69-
return
70-
}
71-
t := fi.ModTime()
72-
hugolib.BuildDate = t.Format(time.RFC3339)
73-
}
74-
75-
// formatBuildDate formats the hugolib.BuildDate according to the value in
76-
// .Params.DateFormat, if it's set.
77-
func formatBuildDate() {
78-
t, _ := time.Parse("2006-01-02T15:04:05-0700", hugolib.BuildDate)
79-
hugolib.BuildDate = t.Format(time.RFC3339)
80-
}

0 commit comments

Comments
 (0)