()
| 276 | } |
| 277 | |
| 278 | func (e *Executor) doVersionChecks() error { |
| 279 | if !e.EnableVersionCheck { |
| 280 | return nil |
| 281 | } |
| 282 | // Copy the version to avoid modifying the original |
| 283 | schemaVersion := &semver.Version{} |
| 284 | *schemaVersion = *e.Taskfile.Version |
| 285 | |
| 286 | // Error if the Taskfile uses a schema version below v3 |
| 287 | if schemaVersion.LessThan(ast.V3) { |
| 288 | return &errors.TaskfileVersionCheckError{ |
| 289 | URI: e.Taskfile.Location, |
| 290 | SchemaVersion: schemaVersion, |
| 291 | Message: `no longer supported. Please use v3 or above`, |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | // Get the current version of Task |
| 296 | // If we can't parse the version (e.g. when its "devel"), then ignore the current version checks |
| 297 | currentVersion, err := semver.NewVersion(version.GetVersion()) |
| 298 | if err != nil { |
| 299 | return nil |
| 300 | } |
| 301 | |
| 302 | // Error if the Taskfile uses a schema version above the current version of Task |
| 303 | if schemaVersion.GreaterThan(currentVersion) { |
| 304 | return &errors.TaskfileVersionCheckError{ |
| 305 | URI: e.Taskfile.Location, |
| 306 | SchemaVersion: schemaVersion, |
| 307 | Message: fmt.Sprintf(`is greater than the current version of Task (%s)`, currentVersion.String()), |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | return nil |
| 312 | } |
no test coverage detected