Skip to content

Commit be4d74f

Browse files
C. Brownkaralabe
authored andcommitted
cmd, internal/build, docker: advertise commit date in unstable build versions (#19522)
* add-date-to unstable * fields-insteadof-split * internal/build: support building with missing git * docker: add git history back to support commit date in version * internal/build: use PR commits hashes for PR builds
1 parent c113723 commit be4d74f

17 files changed

Lines changed: 75 additions & 38 deletions

File tree

‎.dockerignore‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
**/.git
2-
.git
3-
!.git/HEAD
4-
!.git/refs/heads
51
**/*_test.go
62

73
build/_workspace

‎Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Build Geth in a stock Go builder container
22
FROM golang:1.12-alpine as builder
33

4-
RUN apk add --no-cache make gcc musl-dev linux-headers
4+
RUN apk add --no-cache make gcc musl-dev linux-headers git
55

66
ADD . /go-ethereum
77
RUN cd /go-ethereum && make geth

‎Dockerfile.alltools‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Build Geth in a stock Go builder container
22
FROM golang:1.12-alpine as builder
33

4-
RUN apk add --no-cache make gcc musl-dev linux-headers
4+
RUN apk add --no-cache make gcc musl-dev linux-headers git
55

66
ADD . /go-ethereum
77
RUN cd /go-ethereum && make all

‎build/ci.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ func buildFlags(env build.Environment) (flags []string) {
284284
var ld []string
285285
if env.Commit != "" {
286286
ld = append(ld, "-X", "main.gitCommit="+env.Commit)
287+
ld = append(ld, "-X", "main.gitDate="+env.Date)
287288
}
288289
if runtime.GOOS == "darwin" {
289290
ld = append(ld, "-s")

‎cmd/ethkey/main.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ const (
3030

3131
// Git SHA1 commit hash of the release (set via linker flags)
3232
var gitCommit = ""
33+
var gitDate = ""
3334

3435
var app *cli.App
3536

3637
func init() {
37-
app = utils.NewApp(gitCommit, "an Ethereum key manager")
38+
app = utils.NewApp(gitCommit, gitDate, "an Ethereum key manager")
3839
app.Commands = []cli.Command{
3940
commandGenerate,
4041
commandInspect,

‎cmd/evm/main.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ import (
2727
)
2828

2929
var gitCommit = "" // Git SHA1 commit hash of the release (set via linker flags)
30+
var gitDate = ""
3031

3132
var (
32-
app = utils.NewApp(gitCommit, "the evm command line interface")
33+
app = utils.NewApp(gitCommit, gitDate, "the evm command line interface")
3334

3435
DebugFlag = cli.BoolFlag{
3536
Name: "debug",

‎cmd/geth/config.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func loadConfig(file string, cfg *gethConfig) error {
101101
func defaultNodeConfig() node.Config {
102102
cfg := node.DefaultConfig
103103
cfg.Name = clientIdentifier
104-
cfg.Version = params.VersionWithCommit(gitCommit)
104+
cfg.Version = params.VersionWithCommit(gitCommit, gitDate)
105105
cfg.HTTPModules = append(cfg.HTTPModules, "eth", "shh")
106106
cfg.WSModules = append(cfg.WSModules, "eth", "shh")
107107
cfg.IPCPath = "geth.ipc"

‎cmd/geth/consolecmd_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestConsoleWelcome(t *testing.T) {
5050
geth.SetTemplateFunc("goos", func() string { return runtime.GOOS })
5151
geth.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
5252
geth.SetTemplateFunc("gover", runtime.Version)
53-
geth.SetTemplateFunc("gethver", func() string { return params.VersionWithMeta })
53+
geth.SetTemplateFunc("gethver", func() string { return params.VersionWithCommit("", "") })
5454
geth.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
5555
geth.SetTemplateFunc("apis", func() string { return ipcAPIs })
5656

@@ -133,7 +133,7 @@ func testAttachWelcome(t *testing.T, geth *testgeth, endpoint, apis string) {
133133
attach.SetTemplateFunc("goos", func() string { return runtime.GOOS })
134134
attach.SetTemplateFunc("goarch", func() string { return runtime.GOARCH })
135135
attach.SetTemplateFunc("gover", runtime.Version)
136-
attach.SetTemplateFunc("gethver", func() string { return params.VersionWithMeta })
136+
attach.SetTemplateFunc("gethver", func() string { return params.VersionWithCommit("", "") })
137137
attach.SetTemplateFunc("etherbase", func() string { return geth.Etherbase })
138138
attach.SetTemplateFunc("niltime", func() string { return time.Unix(0, 0).Format(time.RFC1123) })
139139
attach.SetTemplateFunc("ipc", func() bool { return strings.HasPrefix(endpoint, "ipc") })

‎cmd/geth/main.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ const (
5050
var (
5151
// Git SHA1 commit hash of the release (set via linker flags)
5252
gitCommit = ""
53+
gitDate = ""
5354
// The app that holds all commands and flags.
54-
app = utils.NewApp(gitCommit, "the go-ethereum command line interface")
55+
app = utils.NewApp(gitCommit, gitDate, "the go-ethereum command line interface")
5556
// flags that configure the node
5657
nodeFlags = []cli.Flag{
5758
utils.IdentityFlag,

‎cmd/geth/misccmd.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ func version(ctx *cli.Context) error {
112112
if gitCommit != "" {
113113
fmt.Println("Git Commit:", gitCommit)
114114
}
115+
if gitDate != "" {
116+
fmt.Println("Git Commit Date:", gitDate)
117+
}
115118
fmt.Println("Architecture:", runtime.GOARCH)
116119
fmt.Println("Protocol Versions:", eth.ProtocolVersions)
117120
fmt.Println("Network Id:", eth.DefaultConfig.NetworkId)

0 commit comments

Comments
 (0)