aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/spf13/cobra/doc
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-05-22 20:53:53 +0200
committerMichael Muré <batolettre@gmail.com>2019-05-22 20:53:53 +0200
commit485ca5900486b7fc3ea71cbcbb39b87272ae09fd (patch)
tree92551be8e01130542f969d06282abfc4a1c43629 /vendor/github.com/spf13/cobra/doc
parente781d6c7fe7dba2fc526c2049aa188c9988e1cf4 (diff)
downloadgit-bug-485ca5900486b7fc3ea71cbcbb39b87272ae09fd.tar.gz
vendor: update dependencies
Diffstat (limited to 'vendor/github.com/spf13/cobra/doc')
-rw-r--r--vendor/github.com/spf13/cobra/doc/man_docs.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/vendor/github.com/spf13/cobra/doc/man_docs.go b/vendor/github.com/spf13/cobra/doc/man_docs.go
index baa48118..4a062339 100644
--- a/vendor/github.com/spf13/cobra/doc/man_docs.go
+++ b/vendor/github.com/spf13/cobra/doc/man_docs.go
@@ -20,6 +20,7 @@ import (
"os"
"path/filepath"
"sort"
+ "strconv"
"strings"
"time"
@@ -87,7 +88,7 @@ type GenManTreeOptions struct {
// GenManHeader is a lot like the .TH header at the start of man pages. These
// include the title, section, date, source, and manual. We will use the
-// current time if Date if unset and will use "Auto generated by spf13/cobra"
+// current time if Date is unset and will use "Auto generated by spf13/cobra"
// if the Source is unset.
type GenManHeader struct {
Title string
@@ -104,14 +105,16 @@ func GenMan(cmd *cobra.Command, header *GenManHeader, w io.Writer) error {
if header == nil {
header = &GenManHeader{}
}
- fillHeader(header, cmd.CommandPath())
+ if err := fillHeader(header, cmd.CommandPath()); err != nil {
+ return err
+ }
b := genMan(cmd, header)
_, err := w.Write(md2man.Render(b))
return err
}
-func fillHeader(header *GenManHeader, name string) {
+func fillHeader(header *GenManHeader, name string) error {
if header.Title == "" {
header.Title = strings.ToUpper(strings.Replace(name, " ", "\\-", -1))
}
@@ -120,12 +123,20 @@ func fillHeader(header *GenManHeader, name string) {
}
if header.Date == nil {
now := time.Now()
+ if epoch := os.Getenv("SOURCE_DATE_EPOCH"); epoch != "" {
+ unixEpoch, err := strconv.ParseInt(epoch, 10, 64)
+ if err != nil {
+ return fmt.Errorf("invalid SOURCE_DATE_EPOCH: %v", err)
+ }
+ now = time.Unix(unixEpoch, 0)
+ }
header.Date = &now
}
header.date = (*header.Date).Format("Jan 2006")
if header.Source == "" {
header.Source = "Auto generated by spf13/cobra"
}
+ return nil
}
func manPreamble(buf *bytes.Buffer, header *GenManHeader, cmd *cobra.Command, dashedName string) {