mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
script: Use source data from environment when generating assets
This commit is contained in:
parent
d60f0e734c
commit
c51365c634
@ -17,6 +17,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
"time"
|
"time"
|
||||||
@ -87,9 +88,17 @@ func main() {
|
|||||||
|
|
||||||
filepath.Walk(flag.Arg(0), walkerFor(flag.Arg(0)))
|
filepath.Walk(flag.Arg(0), walkerFor(flag.Arg(0)))
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
|
|
||||||
|
// Generated time is now, except if the SOURCE_DATE_EPOCH environment
|
||||||
|
// variable is set (for reproducible builds).
|
||||||
|
generated := time.Now().Unix()
|
||||||
|
if s, _ := strconv.ParseInt(os.Getenv("SOURCE_DATE_EPOCH"), 10, 64); s > 0 {
|
||||||
|
generated = s
|
||||||
|
}
|
||||||
|
|
||||||
tpl.Execute(&buf, templateVars{
|
tpl.Execute(&buf, templateVars{
|
||||||
Assets: assets,
|
Assets: assets,
|
||||||
Generated: time.Now().Unix(),
|
Generated: generated,
|
||||||
})
|
})
|
||||||
bs, err := format.Source(buf.Bytes())
|
bs, err := format.Source(buf.Bytes())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user