Debian Codegraph @

debian/patches/0006-Add-variable-for-reproducible-manpage-time-stamps.patch

raw symbols SCIP
1 From: Peymaneh <[email protected]>
2 Date: Sat, 14 Jan 2023 17:54:50 +0100
3 Subject: Add variable for reproducible manpage time stamps
4
5 ---
6 cmd/commands.go | 19 +++++++++++++++++++
7 1 file changed, 19 insertions(+)
8
9 --- a/cmd/commands.go
10 +++ b/cmd/commands.go
11 @@ -21,6 +21,7 @@
12 "regexp"
13 "strings"
14 "sync"
15 + "time"
16
17 "github.com/spf13/cobra"
18 "github.com/spf13/cobra/doc"
19 @@ -28,6 +29,14 @@
20 "github.com/caddyserver/caddy/v2"
21 )
22
23 +// CustomDate will be used by the cobra manpage generator to generate a
24 +// reproducible timestamp. If the "Date" header passed to cobra is empty, it
25 +// will derive the time at build time, which is not reproducible.
26 +// can be passed to during `go build` with `-ldflags`:
27 +//
28 +// -ldflags '-X github.com/caddyserver/caddy/v2/cmd.CustomDate=DD.MM.YYYY'
29 +var CustomDate string
30 +
31 // Command represents a subcommand. Name, Func,
32 // and Short are required.
33 type Command struct {
34 @@ -427,7 +436,16 @@
35 if err := os.MkdirAll(dir, 0o755); err != nil {
36 return caddy.ExitCodeFailedQuit, err
37 }
38 - if err := doc.GenManTree(rootCmd, &doc.GenManHeader{
39 + if CustomDate != "" {
40 + date, _ := time.Parse(time.RFC3339, CustomDate)
41 + if err := doc.GenManTree(rootCmd, &doc.GenManHeader{
42 + Title: "Caddy",
43 + Section: "8", // https://en.wikipedia.org/wiki/Man_page#Manual_sections
44 + Date: &date,
45 + }, dir); err != nil {
46 + return caddy.ExitCodeFailedQuit, err
47 + }
48 + } else if err := doc.GenManTree(rootCmd, &doc.GenManHeader{
49 Title: "Caddy",
50 Section: "8", // https://en.wikipedia.org/wiki/Man_page#Manual_sections
51 }, dir); err != nil {