2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-04-05 05:03:23 +00:00

fix: change how version is retrieved

This commit is contained in:
TorchedSammy 2022-05-16 19:36:34 -04:00
parent cb88db8cfc
commit ac21109307
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
4 changed files with 26 additions and 4 deletions

@ -6,7 +6,7 @@ MY_GOFLAGS = -ldflags "-s -w"
all: dev
dev: MY_GOFLAGS = -ldflags "-s -w -X main.version=$(shell git describe --tags)"
dev: MY_GOFLAGS = -ldflags "-s -w -X main.gitCommit=$(shell git rev-parse --short HEAD) -X main.gitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
dev: build
build:

2
api.go

@ -107,7 +107,7 @@ func hilbishLoad(rtm *rt.Runtime) (rt.Value, func()) {
The nice lil shell for {blue}Lua{reset} fanatics!
Check out the {blue}{bold}guide{reset} command to get started.
`
util.SetFieldProtected(fakeMod, mod, "ver", rt.StringValue(version), "Hilbish version")
util.SetFieldProtected(fakeMod, mod, "ver", rt.StringValue(getVersion()), "Hilbish version")
util.SetFieldProtected(fakeMod, mod, "user", rt.StringValue(username), "Username of user")
util.SetFieldProtected(fakeMod, mod, "host", rt.StringValue(host), "Host name of the machine")
util.SetFieldProtected(fakeMod, mod, "home", rt.StringValue(curuser.HomeDir), "Home directory of the user")

17
main.go

@ -106,7 +106,7 @@ func main() {
}
if *verflag {
fmt.Printf("Hilbish %s\n", version)
fmt.Printf("Hilbish %s\n", getVersion())
os.Exit(0)
}
@ -303,3 +303,18 @@ func exit(code int) {
}
}
}
func getVersion() string {
v := strings.Builder{}
v.WriteString(ver)
if gitBranch != "" && gitBranch != "HEAD" {
v.WriteString("-" + gitBranch)
}
if gitCommit != "" {
v.WriteString("." + gitCommit)
}
return v.String()
}

@ -2,7 +2,6 @@ package main
// String vars that are free to be changed at compile time
var (
version = "v2.0.0"
defaultHistDir = ""
commonRequirePaths = "';./libs/?/init.lua;./?/init.lua;./?/?.lua'"
@ -10,6 +9,14 @@ var (
multilinePrompt = "> "
)
// Version info
var (
ver = "v2.0.0"
releaseName = "Hibiscus"
gitCommit string
gitBranch string
)
// Flags
var (
running bool // Is a command currently running