diff --git a/cmd/task/task.go b/cmd/task/task.go index b33d688e4e..43a8481e6d 100644 --- a/cmd/task/task.go +++ b/cmd/task/task.go @@ -58,6 +58,9 @@ func run() error { dir := flags.Dir entrypoint := flags.Entrypoint + // Initialise version + ver.Init() + if flags.Version { fmt.Printf("Task version: %s\n", ver.GetVersionWithSum()) return nil @@ -132,8 +135,9 @@ func run() error { Stdout: os.Stdout, Stderr: os.Stderr, - OutputStyle: flags.Output, - TaskSorter: taskSorter, + OutputStyle: flags.Output, + TaskSorter: taskSorter, + EnableVersionCheck: true, } listOptions := task.NewListOptions(flags.List, flags.ListAll, flags.ListJson, flags.NoStatus) if err := listOptions.Validate(); err != nil { diff --git a/internal/version/version.go b/internal/version/version.go index 9685b75c85..34a21d4a8b 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -10,7 +10,7 @@ var ( sum = "" ) -func init() { +func Init() { info, ok := debug.ReadBuildInfo() if !ok || info.Main.Version == "" { version = "unknown" diff --git a/setup.go b/setup.go index e7c1be1261..69131d3385 100644 --- a/setup.go +++ b/setup.go @@ -246,7 +246,7 @@ func (e *Executor) setupConcurrencyState() { } func (e *Executor) doVersionChecks() error { - if e.DisableVersionCheck { + if !e.EnableVersionCheck { return nil } // Copy the version to avoid modifying the original diff --git a/task.go b/task.go index ac570e680b..9b554ccf91 100644 --- a/task.go +++ b/task.go @@ -70,13 +70,13 @@ type Executor struct { Stdout io.Writer Stderr io.Writer - Logger *logger.Logger - Compiler *compiler.Compiler - Output output.Output - OutputStyle ast.Output - TaskSorter sort.TaskSorter - UserWorkingDir string - DisableVersionCheck bool + Logger *logger.Logger + Compiler *compiler.Compiler + Output output.Output + OutputStyle ast.Output + TaskSorter sort.TaskSorter + UserWorkingDir string + EnableVersionCheck bool fuzzyModel *fuzzy.Model