From bdb66b09e7e6996429edbbec3afbb99c1ea096bd Mon Sep 17 00:00:00 2001 From: empathetic-alligator Date: Wed, 17 Dec 2014 20:22:51 -0500 Subject: [PATCH] Added /version command that outputs commit the server was built on. --- Makefile | 2 +- client.go | 2 ++ cmd.go | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 065ae1d..6e26b4b 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ all: $(BINARY) go build ./... $(BINARY): **/*.go *.go - go build . + go build -ldflags "-X main.buildCommit `git rev-parse --short HEAD`" . deps: go get . diff --git a/client.go b/client.go index 2c1e0d8..189afcf 100644 --- a/client.go +++ b/client.go @@ -431,6 +431,8 @@ func (c *Client) handleShell(channel ssh.Channel) { } }() } + case "/version": + c.SysMsg("Version " + buildCommit) default: c.SysMsg("Invalid command: %s", line) diff --git a/cmd.go b/cmd.go index 9a36566..34840ad 100644 --- a/cmd.go +++ b/cmd.go @@ -33,6 +33,7 @@ var logLevels = []log.Level{ log.Debug, } +var buildCommit string func main() { options := Options{} parser := flags.NewParser(&options, flags.Default)