fix reproducibility issues

This commit is contained in:
3pleX-dev
2025-04-05 01:27:23 +01:00
parent 3d440cf0f6
commit 1d93982424
2 changed files with 13 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ package cli
import (
"fmt"
"sort"
"strings"
"kitty/tools/cli/markup"
@@ -22,6 +23,7 @@ func fish_completion_script(commands []string) (string, error) {
}
if len(commands) == 0 {
commands = append(commands, utils.Keys(all_commands)...)
sort.Strings(commands)
}
script := strings.Builder{}
script.WriteString(`function __ksi_completions

View File

@@ -9,6 +9,7 @@ import (
"os/exec"
"slices"
"strings"
"strconv"
"time"
"golang.org/x/sys/unix"
@@ -135,6 +136,15 @@ func ShowHelpInPager(text string) {
_ = pager.Run()
}
func getDeterministicTimestamp() time.Time {
if epochStr, exists := os.LookupEnv("SOURCE_DATE_EPOCH"); exists {
if epoch, err := strconv.ParseInt(epochStr, 10, 64); err == nil {
return time.Unix(epoch, 0).UTC()
}
}
return time.Now()
}
func (self *Command) GenerateManPages(level int, recurse bool) (err error) {
var names []string
p := self
@@ -149,7 +159,7 @@ func (self *Command) GenerateManPages(level int, recurse bool) (err error) {
return err
}
defer outf.Close()
fmt.Fprintf(outf, `.TH "%s" "1" "%s" "%s" "%s"`, name, time.Now().Format("Jan 02, 2006"), kitty.VersionString, "kitten Manual")
fmt.Fprintf(outf, `.TH "%s" "1" "%s" "%s" "%s"`, name, getDeterministicTimestamp().Format("Jan 02, 2006"), kitty.VersionString, "kitten Manual")
fmt.Fprintln(outf)
fmt.Fprintln(outf, ".SH Name")
fmt.Fprintln(outf, name, "\\-", escape_text_for_man(self.ShortDescription))