Skip to content

Commit e30ac3d

Browse files
multi: update GetInfoResponse response
Add the `commit_hash` field to the GetInfoResponse. The `commit_hash` field will contain the most recent commit_hash that the build was based on. If the build had uncommitted changes, this field will contain the most recent commit hash, suffixed by "-dirty". The semantics of the `version` field is also updated to always contain the most recent semantic version of the litd node, following the semantic versioning 2.0.0 spec (http://semver.org/).
1 parent 2d3efee commit e30ac3d

File tree

12 files changed

+130
-36
lines changed

12 files changed

+130
-36
lines changed

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ GOIMPORTS_BIN := $(GO_BIN)/gosimports
1616

1717
COMMIT := $(shell git describe --abbrev=40 --dirty --tags)
1818
COMMIT_HASH := $(shell git rev-parse HEAD)
19+
DIRTY := $(shell git diff-index --quiet HEAD -- || echo -dirty)
1920
PUBLIC_URL :=
2021

2122
# GO_VERSION is the Go version used for the release build, docker files, and
@@ -69,6 +70,8 @@ make_ldflags = $(2) -X $(LND_PKG)/build.Commit=lightning-terminal-$(COMMIT) \
6970
-X $(LND_PKG)/build.RawTags=$(shell echo $(1) | sed -e 's/ /,/g') \
7071
-X $(PKG).appFilesPrefix=$(PUBLIC_URL) \
7172
-X $(PKG).Commit=$(COMMIT) \
73+
-X $(PKG).CommitHash=$(COMMIT_HASH) \
74+
-X $(PKG).Dirty=$(DIRTY) \
7275
-X $(LOOP_PKG).Commit=$(LOOP_COMMIT) \
7376
-X $(POOL_PKG).Commit=$(POOL_COMMIT) \
7477
-X $(TAP_PKG).Commit=$(TAP_COMMIT)

app/src/types/generated/proxy_pb.d.ts

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/types/generated/proxy_pb.js

Lines changed: 31 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/litcli/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ var (
7373
func main() {
7474
app := cli.NewApp()
7575

76-
app.Version = terminal.Version()
76+
app.Version = terminal.RichVersion()
7777
app.Name = "litcli"
7878
app.Usage = "control plane for your Lightning Terminal (lit) daemon"
7979
app.Flags = []cli.Flag{

config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
367367
appName := filepath.Base(os.Args[0])
368368
appName = strings.TrimSuffix(appName, filepath.Ext(appName))
369369
if preCfg.ShowVersion {
370-
fmt.Println(appName, "version", Version())
370+
fmt.Println(appName, "version", RichVersion())
371371
os.Exit(0)
372372
}
373373
if preCfg.Lnd.ShowVersion {

litrpc/proxy.pb.go

Lines changed: 37 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

litrpc/proxy.proto

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ message GetInfoRequest {
5252
}
5353

5454
message GetInfoResponse {
55-
// The version of the LiTd software that the node is running.
55+
// The application version of the LiTd software running on the node,
56+
// following the Semantic Versioning 2.0.0 specification
57+
// (http://semver.org/).
5658
string version = 1;
59+
60+
// The Git commit hash the LiTd binary build was based on. If the build had
61+
// uncommited changes, this field will contain the most recent commit hash,
62+
// suffixed by "-dirty".
63+
string commit_hash = 2;
5764
}

litrpc/proxy.swagger.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@
135135
"properties": {
136136
"version": {
137137
"type": "string",
138-
"description": "The version of the LiTd software that the node is running."
138+
"description": "The application version of the LiTd software running on the node,\nfollowing the Semantic Versioning 2.0.0 specification\n(http://semver.org/)."
139+
},
140+
"commit_hash": {
141+
"type": "string",
142+
"description": "The Git commit hash the LiTd binary build was based on. If the build had\nuncommited changes, this field will contain the most recent commit hash,\nsuffixed by \"-dirty\"."
139143
}
140144
}
141145
},

proto/proxy.proto

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ message GetInfoRequest {
5252
}
5353

5454
message GetInfoResponse {
55-
// The version of the LiTd software that the node is running.
55+
// The application version of the LiTd software running on the node,
56+
// following the Semantic Versioning 2.0.0 specification
57+
// (http://semver.org/).
5658
string version = 1;
59+
60+
// The Git commit hash the LiTd binary build was based on. If the build had
61+
// uncommited changes, this field will contain the most recent commit hash,
62+
// suffixed by "-dirty".
63+
string commit_hash = 2;
5764
}

rpc_proxy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ func (p *rpcProxy) GetInfo(_ context.Context, _ *litrpc.GetInfoRequest) (
240240
*litrpc.GetInfoResponse, error) {
241241

242242
return &litrpc.GetInfoResponse{
243-
Version: Version(),
243+
Version: Version(),
244+
CommitHash: CommitHash + Dirty,
244245
}, nil
245246
}
246247

0 commit comments

Comments
 (0)