Skip to content

Commit

Permalink
Merge pull request #25 from jobtalk/fix-update
Browse files Browse the repository at this point in the history
最新版のときはダウンロードしない
  • Loading branch information
shirase_aoi authored Apr 18, 2017
2 parents d7e93cc + 4b8404b commit 14cfbe9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/jobtalk/thor/subcmd/mkelb"
"github.com/jobtalk/thor/subcmd/update"
"github.com/jobtalk/thor/subcmd/vault"
"github.com/jobtalk/thor/vars"
"github.com/mitchellh/cli"
)

Expand All @@ -33,6 +34,10 @@ func init() {
}
VERSION = generateBuildInfo()
log.SetFlags(log.Llongfile)

vars.VERSION = &VERSION
vars.BUILD_DATE = &BUILD_DATE
vars.BUILD_OS = &BUILD_OS
}

func main() {
Expand Down
6 changes: 6 additions & 0 deletions subcmd/update/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"os"
"path/filepath"
"runtime"

"github.com/jobtalk/thor/vars"
)

const (
Expand Down Expand Up @@ -80,6 +82,10 @@ func (c *Update) Run(args []string) int {
platform = "linux-amd64"
}
latest := tags[0].Name
if *vars.VERSION == latest {
fmt.Println("this version is latest")
return 0
}
if latest == "" {
fmt.Println("can not get latest version")
return 255
Expand Down
7 changes: 7 additions & 0 deletions vars/vars.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package vars

var (
VERSION *string
BUILD_DATE *string
BUILD_OS *string
)

0 comments on commit 14cfbe9

Please sign in to comment.