Skip to content

Commit

Permalink
adjusted release comparator based on '>'
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodrigo bernardi committed Oct 2, 2018
1 parent 0d9de80 commit 452781a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions core/main.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
package core

import (
"io/ioutil"
"os"
"path/filepath"

"github.com/Masterminds/semver"
"github.com/hashload/boss/core/git"
"github.com/hashload/boss/env"
"github.com/hashload/boss/models"
"github.com/hashload/boss/msg"
git2 "gopkg.in/src-d/go-git.v4"
"gopkg.in/src-d/go-git.v4/plumbing"
"io/ioutil"
"os"
"path/filepath"
)

var processed = make([]string, 0)

var processedOld = 0
var processedOld = -1

func EnsureDependencies(pkg *models.Package) {
if pkg.Dependencies == nil {
Expand Down Expand Up @@ -50,6 +51,7 @@ func ensureModules(deps []models.Dependency) {
msg.Err("\tVersion type not supported! %s", e)
}
var bestMatch *plumbing.Reference
var bestVersion *semver.Version
hasMatch := false
for _, version := range versions {
short := version.Name().Short()
Expand All @@ -58,11 +60,13 @@ func ensureModules(deps []models.Dependency) {
msg.Warn("\tErro to parse version %s: '%s' in dependency %s", short, err, dep.Repository)
continue
}
validate, _ := constraints.Validate(newVersion)
if validate {
//msg.Debug("Dependency %s with version %s is %s", dep.Repository, newVersion.String(), validate)
if constraints.Check(newVersion) {
//msg.Info("Dependency %s with version %s", dep.Repository, newVersion.String())
hasMatch = true
bestMatch = version
if bestVersion == nil || newVersion.GreaterThan(bestVersion) {
bestMatch = version
bestVersion = newVersion
}
}
}
if !hasMatch {
Expand All @@ -80,7 +84,6 @@ func ensureModules(deps []models.Dependency) {
if err != nil {
msg.Die("\tError on switch to needed version from dependency: %s", dep.Repository)
}
processed = append(processed, dep.GetName())
}
}

Expand Down

0 comments on commit 452781a

Please sign in to comment.