Skip to content

Commit 9a6266f

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 f72cdde commit 9a6266f

File tree

7 files changed

+725
-692
lines changed

7 files changed

+725
-692
lines changed

cmd/loop/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func fatal(err error) {
162162
func main() {
163163
app := cli.NewApp()
164164

165-
app.Version = loop.Version()
165+
app.Version = loop.RichVersion()
166166
app.Name = "loop"
167167
app.Usage = "control plane for your loopd"
168168
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-
infof("Version: %v", loop.Version())
225+
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: 698 additions & 687 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
@@ -967,6 +967,10 @@
967967
"loop_in_stats": {
968968
"$ref": "#/definitions/looprpcLoopStats",
969969
"description": "Statistics about loop ins."
970+
},
971+
"commit_hash": {
972+
"type": "string",
973+
"description": "The git commit hash of the loopd binary."
970974
}
971975
}
972976
},

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 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)