mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-22 08:39:09 +00:00
parent
51dd462c39
commit
13d53b31f1
3 changed files with 1 additions and 49 deletions
8
Gopkg.lock
generated
8
Gopkg.lock
generated
|
@ -143,12 +143,6 @@
|
||||||
revision = "20d3663d4bc9dd10d75abcde9d92e04b4861c674"
|
revision = "20d3663d4bc9dd10d75abcde9d92e04b4861c674"
|
||||||
version = "v1.1.0"
|
version = "v1.1.0"
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
branch = "master"
|
|
||||||
name = "github.com/kardianos/osext"
|
|
||||||
packages = ["."]
|
|
||||||
revision = "ae77be60afb1dcacde03767a8c37337fad28ac14"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/kyokomi/emoji"
|
name = "github.com/kyokomi/emoji"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
|
@ -369,6 +363,6 @@
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "7259b4caf8e75db0b809f06d4897dc870261252e3aecd68ea1348c87a5da9d50"
|
inputs-digest = "823d540219fd336b3a959879fa0018af2a047bd9ffd7d17e44dab15cf76cdc72"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|
|
@ -52,10 +52,6 @@
|
||||||
name = "github.com/jdkato/prose"
|
name = "github.com/jdkato/prose"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
branch = "master"
|
|
||||||
name = "github.com/kardianos/osext"
|
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "github.com/kyokomi/emoji"
|
name = "github.com/kyokomi/emoji"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
|
|
|
@ -14,15 +14,11 @@
|
||||||
package commands
|
package commands
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/helpers"
|
"github.com/gohugoio/hugo/helpers"
|
||||||
"github.com/gohugoio/hugo/hugolib"
|
"github.com/gohugoio/hugo/hugolib"
|
||||||
"github.com/kardianos/osext"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
jww "github.com/spf13/jwalterweatherman"
|
jww "github.com/spf13/jwalterweatherman"
|
||||||
)
|
)
|
||||||
|
@ -38,43 +34,9 @@ var versionCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func printHugoVersion() {
|
func printHugoVersion() {
|
||||||
if hugolib.BuildDate == "" {
|
|
||||||
setBuildDate() // set the build date from executable's mdate
|
|
||||||
} else {
|
|
||||||
formatBuildDate() // format the compile time
|
|
||||||
}
|
|
||||||
if hugolib.CommitHash == "" {
|
if hugolib.CommitHash == "" {
|
||||||
jww.FEEDBACK.Printf("Hugo Static Site Generator v%s %s/%s BuildDate: %s\n", helpers.CurrentHugoVersion, runtime.GOOS, runtime.GOARCH, hugolib.BuildDate)
|
jww.FEEDBACK.Printf("Hugo Static Site Generator v%s %s/%s BuildDate: %s\n", helpers.CurrentHugoVersion, runtime.GOOS, runtime.GOARCH, hugolib.BuildDate)
|
||||||
} else {
|
} else {
|
||||||
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)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// setBuildDate checks the ModTime of the Hugo executable and returns it as a
|
|
||||||
// formatted string. This assumes that the executable name is Hugo, if it does
|
|
||||||
// not exist, an empty string will be returned. This is only called if the
|
|
||||||
// hugolib.BuildDate wasn't set during compile time.
|
|
||||||
//
|
|
||||||
// osext is used for cross-platform.
|
|
||||||
func setBuildDate() {
|
|
||||||
fname, _ := osext.Executable()
|
|
||||||
dir, err := filepath.Abs(filepath.Dir(fname))
|
|
||||||
if err != nil {
|
|
||||||
jww.ERROR.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fi, err := os.Lstat(filepath.Join(dir, filepath.Base(fname)))
|
|
||||||
if err != nil {
|
|
||||||
jww.ERROR.Println(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
t := fi.ModTime()
|
|
||||||
hugolib.BuildDate = t.Format(time.RFC3339)
|
|
||||||
}
|
|
||||||
|
|
||||||
// formatBuildDate formats the hugolib.BuildDate according to the value in
|
|
||||||
// .Params.DateFormat, if it's set.
|
|
||||||
func formatBuildDate() {
|
|
||||||
t, _ := time.Parse("2006-01-02T15:04:05-0700", hugolib.BuildDate)
|
|
||||||
hugolib.BuildDate = t.Format(time.RFC3339)
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue