Skip to content

Commit

Permalink
fix: --version when a version is provided with -ldflags
Browse files Browse the repository at this point in the history
  • Loading branch information
vmaerten committed Jul 5, 2024
1 parent cc14996 commit 3118154
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion internal/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ func init() {
if !ok || info.Main.Version == "" {
version = "unknown"
} else {
version = info.Main.Version
if version == "" {
version = info.Main.Version
}
sum = info.Main.Sum
}
}
Expand Down
3 changes: 1 addition & 2 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ func (e *Executor) doVersionChecks() error {
schemaVersion := &semver.Version{}
*schemaVersion = *e.Taskfile.Version

fmt.Printf("schemaVersion: %v\n", schemaVersion)
// Error if the Taskfile uses a schema version below v3
if schemaVersion.LessThan(ast.V3) {
return &errors.TaskfileVersionCheckError{
Expand All @@ -257,14 +258,12 @@ func (e *Executor) doVersionChecks() error {
Message: `no longer supported. Please use v3 or above`,
}
}

// Get the current version of Task
// If we can't parse the version (e.g. when its "devel"), then ignore the current version checks
currentVersion, err := semver.NewVersion(version.GetVersion())
if err != nil {
return nil
}

// Error if the Taskfile uses a schema version above the current version of Task
if schemaVersion.GreaterThan(currentVersion) {
return &errors.TaskfileVersionCheckError{
Expand Down

0 comments on commit 3118154

Please sign in to comment.