1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-26 09:00:57 +02:00

version with tag

This commit is contained in:
Jesse Duffield 2018-08-08 18:57:27 +10:00
parent c6aee678c0
commit fbadbdd771
3 changed files with 14 additions and 13 deletions

View File

@ -26,7 +26,7 @@ script:
# - go get -v ./...
# - diff -u <(echo -n) <(gofmt -d .) # can't make gofmt ignore vendor directory
# - go vet $(go list ./... | grep -v /vendor/)
- if [ "${LATEST}" = "true" ]; then gox -os="linux darwin windows" -arch="amd64" -ldflags "-X main.Rev=`git rev-parse --short HEAD` -X main.builddate=`date -u +%Y%m%d.%H%M%S`" -verbose ./...; fi
- if [ "${LATEST}" = "true" ]; then gox -os="linux darwin windows" -arch="amd64" -ldflags "-X main.Rev=`git rev-parse --short HEAD` -X main.builddate=`date -u +%Y%m%d.%H%M%S` -X main.Version=${TRAVIS_TAG}" -verbose ./...; fi
- mv lazygit_windows_amd64.exe lazygit_windows_amd64_${TRAVIS_TAG}.exe
- mv lazygit_darwin_amd64 lazygit_darwin_amd64_${TRAVIS_TAG}
- mv lazygit_linux_amd64 lazygit_linux_amd64_${TRAVIS_TAG}

11
gui.go
View File

@ -225,12 +225,7 @@ func layout(g *gocui.Gui) error {
v.FgColor = gocui.ColorWhite
}
version := Rev
if version == "" {
version = "unversioned"
}
if v, err := g.SetView("options", -1, optionsTop, width-len(version)-2, optionsTop+2, 0); err != nil {
if v, err := g.SetView("options", -1, optionsTop, width-len(Version)-2, optionsTop+2, 0); err != nil {
if err != gocui.ErrUnknownView {
return err
}
@ -239,14 +234,14 @@ func layout(g *gocui.Gui) error {
v.Frame = false
}
if v, err := g.SetView("version", width-len(version)-1, optionsTop, width, optionsTop+2, 0); err != nil {
if v, err := g.SetView("version", width-len(Version)-1, optionsTop, width, optionsTop+2, 0); err != nil {
if err != gocui.ErrUnknownView {
return err
}
v.BgColor = gocui.ColorDefault
v.FgColor = gocui.ColorGreen
v.Frame = false
renderString(g, "version", version)
renderString(g, "version", Version)
// these are only called once
handleFileSelect(g, filesView)

14
main.go
View File

@ -12,9 +12,15 @@ import (
)
var (
startTime time.Time
debugging bool
Rev string
startTime time.Time
debugging bool
// Rev - Git Revision
Rev string
// Version - Version number
Version = "unversioned"
builddate string
debuggingPointer = flag.Bool("debug", false, "a boolean")
versionFlag = flag.Bool("v", false, "Print the current version")
@ -67,7 +73,7 @@ func main() {
devLog("\n\n\n\n\n\n\n\n\n\n")
flag.Parse()
if *versionFlag {
fmt.Printf("rev=%s, build date=%s", Rev, builddate)
fmt.Printf("rev=%s, build date=%s, version=%s", Rev, builddate, Version)
os.Exit(0)
}
verifyInGitRepo()