Skip to content

Commit 989f163

Browse files
committed
loop: add the commit_hash to GetInfoResponse, change version semantics
With this commit we extend GetinfoResponse with the strict commit hash (which also includes whether the build tree was clean or dirty).
1 parent cd7b3b6 commit 989f163

File tree

7 files changed

+705
-672
lines changed

7 files changed

+705
-672
lines changed

cmd/loop/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func fatal(err error) {
151151
func main() {
152152
app := cli.NewApp()
153153

154-
app.Version = loop.Version()
154+
app.Version = loop.RichVersion()
155155
app.Name = "loop"
156156
app.Usage = "control plane for your loopd"
157157
app.Flags = []cli.Flag{

loopd/run.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ func Run(rpcCfg RPCConfig) error {
176176
appName := filepath.Base(os.Args[0])
177177
appName = strings.TrimSuffix(appName, filepath.Ext(appName))
178178
if config.ShowVersion {
179-
fmt.Println(appName, "version", loop.Version())
179+
fmt.Println(appName, "version", loop.RichVersion())
180180
os.Exit(0)
181181
}
182182

@@ -222,7 +222,7 @@ func Run(rpcCfg RPCConfig) error {
222222
}
223223

224224
// Print the version before executing either primary directive.
225-
log.Infof("Version: %v", loop.Version())
225+
log.Infof("Version: %v", loop.RichVersion())
226226

227227
lisCfg := NewListenerConfig(&config, rpcCfg)
228228

loopd/swapclient_server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ func (s *swapClientServer) GetInfo(ctx context.Context,
12101210

12111211
return &looprpc.GetInfoResponse{
12121212
Version: loop.Version(),
1213+
CommitHash: loop.CommitHash(),
12131214
Network: s.config.Network,
12141215
RpcListen: s.config.RPCListen,
12151216
RestListen: s.config.RESTListen,

looprpc/client.pb.go

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

looprpc/client.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,11 @@ message GetInfoResponse {
10451045
Statistics about loop ins.
10461046
*/
10471047
LoopStats loop_in_stats = 8;
1048+
1049+
/*
1050+
The git commit hash of the loopd binary.
1051+
*/
1052+
string commit_hash = 9;
10481053
}
10491054

10501055
message GetLiquidityParamsRequest {

looprpc/client.swagger.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,10 @@
953953
"loop_in_stats": {
954954
"$ref": "#/definitions/looprpcLoopStats",
955955
"description": "Statistics about loop ins."
956+
},
957+
"commit_hash": {
958+
"type": "string",
959+
"description": "The git commit hash of the loopd binary."
956960
}
957961
}
958962
},

version.go

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,25 @@ const (
4545
var AgentName = defaultAgentName
4646

4747
// Version returns the application version as a properly formed string per the
48-
// semantic versioning 2.0.0 spec (http://semver.org/) and the commit it was
49-
// built on.
48+
// semantic versioning 2.0.0 spec (http://semver.org/).
5049
func Version() string {
50+
// Append commit hash of current build to version.
51+
return semanticVersion()
52+
}
53+
54+
// RichVersion returns the application version as a properly formed string
55+
// per the semantic versioning 2.0.0 spec (http://semver.org/) and the commit
56+
// it was built on.
57+
func RichVersion() string {
5158
// Append commit hash of current build to version.
5259
return fmt.Sprintf("%s commit=%s", semanticVersion(), Commit)
5360
}
5461

62+
// CommitHash returns the commit hash of the current build.
63+
func CommitHash() string {
64+
return fmt.Sprintf("%s", Commit)
65+
}
66+
5567
// UserAgent returns the full user agent string that identifies the software
5668
// that is submitting swaps to the loop server.
5769
func UserAgent(initiator string) string {

0 commit comments

Comments
 (0)