From 2eff2a35598e414fd7525a65a28960efba1674de Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 27 Oct 2021 12:06:54 -0400 Subject: [PATCH] use tag info in version --- Makefile | 3 ++- main.go | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 03f75d2..a34ec20 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,13 @@ GOFILES=$(wildcard *.go) PROG=simpbot #set variables GIT_COMMIT := $(shell git rev-list -1 HEAD) +GIT_TAG := $(shell git describe --tags | cut -d- -f1) ifeq ($(PREFIX),) # PREFIX is environment variable, but if it is not set, then set default value PREFIX := /usr/local endif $(PROG): $(GOFILES) - go build -ldflags "-X main.GitCommit=$(GIT_COMMIT)" + go build -ldflags "-X main.GitCommit=$(GIT_COMMIT) -X main.GitTag=$(GIT_TAG)" clean: rm -f simpbot diff --git a/main.go b/main.go index 70aa75b..92b2939 100644 --- a/main.go +++ b/main.go @@ -22,6 +22,7 @@ var Password string var DimensionServer string var HomeserverDomain string var GitCommit string +var GitTag string var Statefile string var CurrStreamCnt int var MostStreamCnt int @@ -100,11 +101,15 @@ func main() { vlist = append(vlist, fmt.Sprintf("%v Total:%v", vt.Name, vt.TotalStreams)) t = t + vt.TotalStreams } - statmsg = fmt.Sprintf("Current Stats Since %v:\n%v\nTotal Streams: %v\nMost Concurrent: %v/%v\n", StartTime, strings.Join(vlist, "\n"), t, MostStreamCnt, len(vtubers)) + statmsg = fmt.Sprintf("Current Stats Since %v:\n%v\n\nTotal Streams: %v\nMost Concurrent: %v/%v\n", StartTime, strings.Join(vlist, "\n"), t, MostStreamCnt, len(vtubers)) client.SendText(evt.RoomID, statmsg) case "version": // print version - client.SendText(evt.RoomID, "SimpBot version "+GitCommit) + if GitTag != "" { + client.SendText(evt.RoomID, "SimpBot version "+GitTag) + } else { + client.SendText(evt.RoomID, "SimpBot version "+GitCommit) + } case "reload": //reload config client.SendText(evt.RoomID, "Reloading config")