Add git hash/tag to the about string

This commit is contained in:
Nonoo 2020-10-26 09:44:12 +01:00
parent 18b6e1f827
commit 45b1076b78
3 changed files with 16 additions and 3 deletions

2
.vscode/tasks.json vendored
View file

@ -4,7 +4,7 @@
"version": "2.0.0", "version": "2.0.0",
"tasks": [ "tasks": [
{ {
"label": "debug", "label": "build",
"type": "shell", "type": "shell",
"command": "build/build.sh", "command": "build/build.sh",
"problemMatcher": [], "problemMatcher": [],

View file

@ -11,4 +11,6 @@ scriptdir=`pwd`
cd .. cd ..
go build git_tag=`git describe --exact-match HEAD 2>/dev/null`
git_hash=`git log --pretty=format:'%h' -n 1`
go build -ldflags "-X main.gitTag=$git_tag -X main.gitHash=$git_hash"

13
main.go
View file

@ -8,10 +8,21 @@ import (
"time" "time"
) )
var gitTag string
var gitHash string
var gotErrChan = make(chan bool) var gotErrChan = make(chan bool)
func getAboutStr() string { func getAboutStr() string {
return "kappanhang by Norbert Varga HA2NON and Akos Marton ES1AKOS https://github.com/nonoo/kappanhang" var v string
if gitTag != "" {
v = gitTag
} else if gitHash != "" {
v = gitTag
} else {
v = "debug"
}
return "kappanhang " + v + " by Norbert Varga HA2NON and Akos Marton ES1AKOS https://github.com/nonoo/kappanhang"
} }
func runControlStream(osSignal chan os.Signal) (shouldExit bool, exitCode int) { func runControlStream(osSignal chan os.Signal) (shouldExit bool, exitCode int) {