Skip to content

Commit 89e7b35

Browse files
committed
Create EnableVersionCheck flag
1 parent 36edfc8 commit 89e7b35

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

cmd/task/task.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ func run() error {
5858
dir := flags.Dir
5959
entrypoint := flags.Entrypoint
6060

61+
// Initialise version
62+
ver.Init()
63+
6164
if flags.Version {
6265
fmt.Printf("Task version: %s\n", ver.GetVersionWithSum())
6366
return nil
@@ -132,8 +135,9 @@ func run() error {
132135
Stdout: os.Stdout,
133136
Stderr: os.Stderr,
134137

135-
OutputStyle: flags.Output,
136-
TaskSorter: taskSorter,
138+
OutputStyle: flags.Output,
139+
TaskSorter: taskSorter,
140+
EnableVersionCheck: true,
137141
}
138142
listOptions := task.NewListOptions(flags.List, flags.ListAll, flags.ListJson, flags.NoStatus)
139143
if err := listOptions.Validate(); err != nil {

internal/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var (
1010
sum = ""
1111
)
1212

13-
func init() {
13+
func Init() {
1414
info, ok := debug.ReadBuildInfo()
1515
if !ok || info.Main.Version == "" {
1616
version = "unknown"

setup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ func (e *Executor) setupConcurrencyState() {
246246
}
247247

248248
func (e *Executor) doVersionChecks() error {
249-
if e.DisableVersionCheck {
249+
if !e.EnableVersionCheck {
250250
return nil
251251
}
252252
// Copy the version to avoid modifying the original

task.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ type Executor struct {
7070
Stdout io.Writer
7171
Stderr io.Writer
7272

73-
Logger *logger.Logger
74-
Compiler *compiler.Compiler
75-
Output output.Output
76-
OutputStyle ast.Output
77-
TaskSorter sort.TaskSorter
78-
UserWorkingDir string
79-
DisableVersionCheck bool
73+
Logger *logger.Logger
74+
Compiler *compiler.Compiler
75+
Output output.Output
76+
OutputStyle ast.Output
77+
TaskSorter sort.TaskSorter
78+
UserWorkingDir string
79+
EnableVersionCheck bool
8080

8181
fuzzyModel *fuzzy.Model
8282

0 commit comments

Comments
 (0)