mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-13 13:59:06 +02:00
use fallback file VERSION
This commit is contained in:
parent
273eb6244b
commit
6e8abbcdda
15
main.go
15
main.go
@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"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() {
|
func main() {
|
||||||
startTime = time.Now()
|
startTime = time.Now()
|
||||||
devLog("\n\n\n\n\n\n\n\n\n\n")
|
devLog("\n\n\n\n\n\n\n\n\n\n")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
if version == "unversioned" {
|
||||||
|
version = fallbackVersion()
|
||||||
|
}
|
||||||
if *versionFlag {
|
if *versionFlag {
|
||||||
fmt.Printf("commit=%s, build date=%s, version=%s", commit, date, version)
|
fmt.Printf("commit=%s, build date=%s, version=%s", commit, date, version)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user