Skip to content

Commit

Permalink
Merge pull request #285 from mnm678/reproducible_builds
Browse files Browse the repository at this point in the history
Added SOURCE_DATE_EPOCH for reproducible builds
  • Loading branch information
jessevdk authored Dec 21, 2018
2 parents 57c9cb6 + 4981010 commit a1c83c9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions man.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package flags
import (
"fmt"
"io"
"os"
"runtime"
"strconv"
"strings"
"time"
)
Expand Down Expand Up @@ -175,6 +177,14 @@ func writeManPageCommand(wr io.Writer, name string, root *Command, command *Comm
// writer.
func (p *Parser) WriteManPage(wr io.Writer) {
t := time.Now()
source_date_epoch := os.Getenv("SOURCE_DATE_EPOCH")
if source_date_epoch != "" {
sde, err := strconv.ParseInt(source_date_epoch, 10, 64)
if err != nil {
panic(fmt.Sprintf("Invalid SOURCE_DATE_EPOCH: %s", err))
}
t = time.Unix(sde, 0)
}

fmt.Fprintf(wr, ".TH %s 1 \"%s\"\n", manQuote(p.Name), t.Format("2 January 2006"))
fmt.Fprintln(wr, ".SH NAME")
Expand Down

0 comments on commit a1c83c9

Please sign in to comment.