From 69e63b529ae16d9f26ed67b2831d0c1756ef267d Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Wed, 31 Jan 2024 22:51:00 +0100 Subject: main: improve version string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Initialize a build variable to the date on which the binary was generated. Include the date in the build info string which is output when running aerc -v and in the crash logs. Do not rely on parsing the build flags via some obscure base64 voodoo to determine if notmuch support is available or not. Instead, use the symbols from the linked library directly if available. Before: $ aerc -v 0.16.0-183-g4cc2e6be3a01 +notmuch (go1.21.6 amd64 linux) After: $ aerc -v aerc 0.16.0-183-g4cc2e6be3a01 +notmuch-5.6.0 (go1.21.6 amd64 linux 2024-01-31) Signed-off-by: Robin Jarry Acked-by: CiarĂ¡n Ainsworth --- main.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index 5d79428d..8f5ec2f9 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "bytes" "context" - "encoding/base64" "errors" "fmt" "math/rand" @@ -21,6 +20,7 @@ import ( "git.sr.ht/~rjarry/aerc/app" "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/config" + "git.sr.ht/~rjarry/aerc/lib" "git.sr.ht/~rjarry/aerc/lib/crypto" "git.sr.ht/~rjarry/aerc/lib/hooks" "git.sr.ht/~rjarry/aerc/lib/ipc" @@ -85,17 +85,16 @@ func getCompletions(cmdline string) ([]string, string) { // set at build time var ( Version string - Flags string + Date string ) func buildInfo() string { info := Version - flags, _ := base64.StdEncoding.DecodeString(Flags) - if strings.Contains(string(flags), "notmuch") { - info += " +notmuch" + if soVersion, hasNotmuch := lib.NotmuchVersion(); hasNotmuch { + info += fmt.Sprintf(" +notmuch-%s", soVersion) } - info += fmt.Sprintf(" (%s %s %s)", - runtime.Version(), runtime.GOARCH, runtime.GOOS) + info += fmt.Sprintf(" (%s %s %s %s)", + runtime.Version(), runtime.GOARCH, runtime.GOOS, Date) return info } @@ -157,7 +156,7 @@ Options: } func (o *Opts) ShowVersion(arg string) error { - fmt.Println(log.BuildInfo) + fmt.Println("aerc " + log.BuildInfo) os.Exit(0) return nil } -- cgit