summaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2018-08-09 12:25:32 +1000
committerJesse Duffield <jessedduffield@gmail.com>2018-08-09 12:25:32 +1000
commit6e8abbcddad641a000c45985b22a8d0899f02781 (patch)
treeeb1716d5211af0fe2c213c9bdfa81897fb5d0af8 /main.go
parent273eb6244b267f5686903ce6194421ad7c9e3ba9 (diff)
use fallback file VERSION
Diffstat (limited to 'main.go')
-rw-r--r--main.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/main.go b/main.go
index 93be5824e..6ad705dd1 100644
--- a/main.go
+++ b/main.go
@@ -4,6 +4,7 @@ import (
"errors"
"flag"
"fmt"
+ "io/ioutil"
"log"
"os"
"os/exec"
@@ -69,10 +70,24 @@ func navigateToRepoRootDirectory() {
}
}
+// when building the binary, `version` is set as a compile-time variable, along
+// with `date` and `commit`. If this program has been opened directly via go,
+// we will populate the `version` with VERSION in the lazygit root directory
+func fallbackVersion() string {
+ byteVersion, err := ioutil.ReadFile("VERSION")
+ if err != nil {
+ log.Panicln(err.Error())
+ }
+ return string(byteVersion)
+}
+
func main() {
startTime = time.Now()
devLog("\n\n\n\n\n\n\n\n\n\n")
flag.Parse()
+ if version == "unversioned" {
+ version = fallbackVersion()
+ }
if *versionFlag {
fmt.Printf("commit=%s, build date=%s, version=%s", commit, date, version)
os.Exit(0)