From 79f471a5d92866410dac6096235c176e27447168 Mon Sep 17 00:00:00 2001 From: Jrelvas <55360900+Noted-Jrelvas@users.noreply.github.com> Date: Wed, 22 Nov 2023 19:21:46 +0000 Subject: [PATCH] sysinfo: Display git head sha1 Now Vinegar is built with head's latest commit sha, which is shown in sysinfo's output. If the sha can't be determined (for instance, if vinegar was built from a tarball with no git info), it's displayed as N/A --- Makefile | 3 ++- cmd/vinegar/vinegar.go | 11 +++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 741755a..873e17f 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,10 @@ FLATPAK = io.github.vinegarhq.Vinegar GO = go GO_LDFLAGS = -s -w +GIT_HEAD = $(shell git log -1 --pretty=format:"%H") VINEGAR_ICONPATH = $(ICONPREFIX)/64x64/apps/$(FLATPAK).png -VINEGAR_LDFLAGS = $(GO_LDFLAGS) -X main.BinPrefix=$(BINPREFIX) -X main.Version=$(VERSION) +VINEGAR_LDFLAGS = $(GO_LDFLAGS) -X main.BinPrefix=$(BINPREFIX) -X main.Version=$(VERSION) -X main.GitHead=$(GIT_HEAD) VINEGAR_GOFLAGS = --tags nowayland,novulkan all: vinegar robloxmutexer.exe diff --git a/cmd/vinegar/vinegar.go b/cmd/vinegar/vinegar.go index 7335ff4..4cdc8ac 100644 --- a/cmd/vinegar/vinegar.go +++ b/cmd/vinegar/vinegar.go @@ -22,6 +22,7 @@ import ( var ( BinPrefix string Version string + GitHead string ) func usage() { @@ -130,6 +131,12 @@ func Delete() { } func Sysinfo(pfx *wine.Prefix) { + fmtHead := GitHead + + if fmtHead == "" { + fmtHead = "N/A" + } + cmd := pfx.Wine("--version") cmd.Stdout = nil // required for Output() ver, err := cmd.Output() @@ -137,14 +144,14 @@ func Sysinfo(pfx *wine.Prefix) { log.Fatal(err) } - info := `* Vinegar: %s + info := `* Vinegar: %s (%s) * Distro: %s * Processor: %s * Supports AVX: %t * Kernel: %s * Wine: %s` - fmt.Printf(info, Version, sysinfo.Distro, sysinfo.CPU, sysinfo.HasAVX, sysinfo.Kernel, ver) + fmt.Printf(info, Version, fmtHead, sysinfo.Distro, sysinfo.CPU, sysinfo.HasAVX, sysinfo.Kernel, ver) if sysinfo.InFlatpak { fmt.Println("* Flatpak: [x]") }