MCPcopy
hub / github.com/go-task/task / doVersionChecks

Method doVersionChecks

setup.go:278–312  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

276}
277
278func (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}

Callers 1

SetupMethod · 0.95

Calls 2

GetVersionFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected