// Match a given version againts the constraint
761411
func (self *Constraint) Match(version string) bool {
	return Compare(version, self.version, self.operator)
}
1148527
func (r *ReindexDestination) Version(version int64) *ReindexDestination {
	r.version = version
	return r
}
600808
func (v Version) Compare(o Version) int {
	if v.Major != o.Major {
		if v.Major > o.Major {
			return 1
		}
		return -1
	}
	if v.Minor != o.Minor {
		if v.Minor > o.Minor {
			return 1
		}
		return -1
	}
	if v.Patch != o.Patch {
		if v.Patch > o.Patch {
			return 1
		}
		return -1
	}

	// Quick comparison if a version has no prerelease versions
	if len(v.Pre) == 0 && len(o.Pre) == 0 {
		return 0
	} else if len(v.Pre) == 0 && len(o.Pre) > 0 {
		return 1
	} else if len(v.Pre) > 0 && len(o.Pre) == 0 {
		return -1
	}

	i := 0
	for ; i < len(v.Pre) && i < len(o.Pre); i++ {
		if comp := v.Pre[i].Compare(o.Pre[i]); comp == 0 {
			continue
		} else if comp == 1 {
			return 1
		} else {
			return -1
		}
	}

	// If all pr versions are the equal but one has further prversion, this one greater
	if i == len(v.Pre) && i == len(o.Pre) {
		return 0
	} else if i == len(v.Pre) && i < len(o.Pre) {
		return -1
	} else {
		return 1
	}

}
564367
func (p *JsonPairs) Match(k string) string {
	for _, j := range *p {
		if j.K == k {
			return j.V
		}
	}
	return ""
}
1275524
func (c *constraint) check(v *Version) bool {
	return c.function(v, c)
}
1343127
func CompareVersions(v1, v2 string) int {
	maxlen := 1
	s1 := strings.Split(v1, ".")
	s2 := strings.Split(v2, ".")
	for _, s := range append(s1, s2...) {
		if len(s) > maxlen {
			maxlen = len(s)
		}
	}
	if len(s1) > len(s2) {
		t := make([]string, len(s1))
		copy(t, s2)
		s2 = t
	}
	if len(s2) > len(s1) {
		t := make([]string, len(s2))
		copy(t, s1)
		s1 = t
	}
	format := fmt.Sprintf("%%0%ds", maxlen)
	for i := 0; i < len(s1); i++ {
		scomp := strings.Compare(fmt.Sprintf(format, s1[i]), fmt.Sprintf(format, s2[i]))
		if scomp != 0 {
			return scomp
		}
	}
	return 0
}
409029
func (f Filter) match(agent HasVersion) bool {
	if f.Number != version.Zero && agent.AgentVersion() != f.Number {
		return false
	}
	tools, ok := agent.(*Tools)
	if !ok {
		return true
	}
	if f.Series != "" && tools.Version.Series != f.Series {
		return false
	}
	if f.Arch != "" && tools.Version.Arch != f.Arch {
		return false
	}
	return true
}
1060351
func (w *Wildmatch) Match(t string) bool {
	dirs, ok := w.consume(t, MatchOpts{})
	if !ok {
		return false
	}
	return len(dirs) == 0
}
659369
func (s *ScanService) Version(version bool) *ScanService {
	s.searchSource = s.searchSource.Version(version)
	return s
}
452101
func (vu versionUnifier) matchesAny(id ProjectIdentifier, c1, c2 Constraint) bool {
	if c1.MatchesAny(c2) {
		return true
	}

	vu.mtr.push("b-matches-any")
	// This approach is slightly wasteful, but just SO much less verbose, and
	// more easily understood.
	var uc1, uc2 Constraint
	if v1, ok := c1.(Version); ok {
		uc1 = vu.createTypeUnion(id, v1)
	} else {
		uc1 = c1
	}

	if v2, ok := c2.(Version); ok {
		uc2 = vu.createTypeUnion(id, v2)
	} else {
		uc2 = c2
	}

	vu.mtr.pop()
	return uc1.MatchesAny(uc2)
}
149266
func constraintTildeOrEqual(v *Version, c *constraint) bool {
	// If there is a pre-release on the version but the constraint isn't looking
	// for them assume that pre-releases are not compatible. See issue 21 for
	// more details.
	if v.Prerelease() != "" && c.con.Prerelease() == "" {
		return false
	}

	if c.dirty {
		c.msg = constraintMsg["~"]
		return constraintTilde(v, c)
	}

	return v.Equal(c.con)
}
83164
func (m *InMem) Version(context.Context) semver.Version {
	return semver.Version{Major: 1}
}
225615
func Normalize(version string) string {

	// ignore aliases and just assume the alias is required instead of the source
	result := RegFind(`^([^,\s]+) +as +([^,\s]+)$`, version)
	if result != nil {
		version = result[1]
	}

	// match master-like branches
	if regexpMasterLikeBranches.MatchString(strings.ToLower(version)) {
		return "9999999-dev"
	}

	if strings.HasPrefix(strings.ToLower(version), "dev-") {
		return "dev-" + version[4:len(version)]
	}

	index := 0

	// match classical versioning
	result = RegFind(`(?i)^v?(\d{1,3})(\.\d+)?(\.\d+)?(\.\d+)?`+modifierRegex+`$`, version)
	if result != nil {
		version = ""
		for _, val := range result[1:5] {
			if val != "" {
				version = version + val
			} else {
				version = version + ".0"
			}
		}

		index = 5
	} else {
		// match date-based versioning
		result = RegFind(`(?i)^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)`+modifierRegex+`$`, version)
		if result != nil {
			version = regexp.MustCompile(`\D`).ReplaceAllString(result[1], "-")
			index = 2
		}
	}

	if index != 0 {
		if result[index] != "" {
			if result[index] == "stable" {
				return version
			}

			version = version + "-" + expandStability(result[index])
			if result[index+1] != "" {
				version = version + result[index+1]
			}
		}

		if result[index+2] != "" {
			version = version + "-dev"
		}

		return version
	}

	result = RegFind(`(?i)(.*?)[.-]?dev$`, version)
	if result != nil {
		return normalizeBranch(result[1])
	}

	return version
}
236369
func If(v string, is string) bool {
	ver, err := version.NewVersion(v)
	if err != nil {
		return false
	}

	constraints, err := version.NewConstraint(is)
	if err != nil {
		return false
	}

	return constraints.Check(ver)
}
395822
func constraintNotEqual(v *Version, c *constraint) bool {
	if c.dirty {

		// If there is a pre-release on the version but the constraint isn't looking
		// for them assume that pre-releases are not compatible. See issue 21 for
		// more details.
		if v.Prerelease() != "" && c.con.Prerelease() == "" {
			return false
		}

		if c.con.Major() != v.Major() {
			return true
		}
		if c.con.Minor() != v.Minor() && !c.minorDirty {
			return true
		} else if c.minorDirty {
			return false
		}

		return false
	}

	return !v.Equal(c.con)
}
432207
func Match(methods []string, path string, h interface{}, m ...interface{}) {
	Default.Match(methods, path, h, m...)
}
999181
func (d *DateString) Match(value string) bool {
	return d.Regexp.Match([]byte(value))
}