Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ GOBUILD := GO111MODULE=on go build -v
GOINSTALL := GO111MODULE=on go install -v
GOMOD := GO111MODULE=on go mod

COMMIT := $(shell git describe --abbrev=40 --dirty)
COMMIT := $(shell git describe --abbrev=40 --dirty | sed -E 's/.*-g([0-9a-f]{40})(-dirty)?/\1\2/')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

LDFLAGS := -ldflags "-X $(PKG).Commit=$(COMMIT)"
DEV_TAGS = dev

Expand Down
2 changes: 1 addition & 1 deletion cmd/loop/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func fatal(err error) {
func main() {
app := cli.NewApp()

app.Version = loop.Version()
app.Version = loop.RichVersion()
app.Name = "loop"
app.Usage = "control plane for your loopd"
app.Flags = []cli.Flag{
Expand Down
4 changes: 2 additions & 2 deletions loopd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ func Run(rpcCfg RPCConfig) error {
appName := filepath.Base(os.Args[0])
appName = strings.TrimSuffix(appName, filepath.Ext(appName))
if config.ShowVersion {
fmt.Println(appName, "version", loop.Version())
fmt.Println(appName, "version", loop.RichVersion())
os.Exit(0)
}

Expand Down Expand Up @@ -222,7 +222,7 @@ func Run(rpcCfg RPCConfig) error {
}

// Print the version before executing either primary directive.
infof("Version: %v", loop.Version())
infof("Version: %v", loop.RichVersion())

lisCfg := NewListenerConfig(&config, rpcCfg)

Expand Down
1 change: 1 addition & 0 deletions loopd/swapclient_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@ func (s *swapClientServer) GetInfo(ctx context.Context,

return &looprpc.GetInfoResponse{
Version: loop.Version(),
CommitHash: loop.CommitHash(),
Network: s.config.Network,
RpcListen: s.config.RPCListen,
RestListen: s.config.RESTListen,
Expand Down
1,385 changes: 698 additions & 687 deletions looprpc/client.pb.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions looprpc/client.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,11 @@ message GetInfoResponse {
Statistics about loop ins.
*/
LoopStats loop_in_stats = 8;

/*
The git commit hash of the loopd binary.
*/
string commit_hash = 9;
}

message GetLiquidityParamsRequest {
Expand Down
4 changes: 4 additions & 0 deletions looprpc/client.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,10 @@
"loop_in_stats": {
"$ref": "#/definitions/looprpcLoopStats",
"description": "Statistics about loop ins."
},
"commit_hash": {
"type": "string",
"description": "The git commit hash of the loopd binary."
}
}
},
Expand Down
16 changes: 14 additions & 2 deletions version.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,25 @@ const (
var AgentName = defaultAgentName

// Version returns the application version as a properly formed string per the
// semantic versioning 2.0.0 spec (http://semver.org/) and the commit it was
// built on.
// semantic versioning 2.0.0 spec (http://semver.org/).
func Version() string {
// Append commit hash of current build to version.
return semanticVersion()
}

// RichVersion returns the application version as a properly formed string
// per the semantic versioning 2.0.0 spec (http://semver.org/) and the commit
// it was built on.
func RichVersion() string {
// Append commit hash of current build to version.
return fmt.Sprintf("%s commit=%s", semanticVersion(), Commit)
}

// CommitHash returns the commit hash of the current build.
func CommitHash() string {
return Commit
}

// UserAgent returns the full user agent string that identifies the software
// that is submitting swaps to the loop server.
func UserAgent(initiator string) string {
Expand Down