If a version string is provided, validates it. Otherwise it tries
    to determine the current version from the last Git tag that matches
    ``tag_pattern`` option.

    Return a :class:`~braulio.version.Version` object or **None**.
979364
def current_version_option_validator(ctx, param, value):
    

    current_version = None

    if value:
        try:
            current_version = Version(value)
        except ValueError:
            ctx.fail(f"{value} is not a valid version string")

    # Look for the last git tag for the curren version
    git = Git()
    tag_pattern = ctx.params["tag_pattern"]
    versions = tag_analyzer(git.tags, tag_pattern, Version)

    # User provided current version. Try to find a tag that match it.
    if current_version:
        for version in versions:
            if version == current_version:
                current_version = version
                break
    elif versions:
        current_version = versions[0]

    ctx.params["current_tag"] = current_version.tag if current_version else None
    ctx.params["versions"] = versions

    return current_version
1270750
def _extract_version(version_string, pattern):
    
    if version_string:
        match = pattern.match(version_string.strip())
        if match:
            return match.group(1)
    return ""
1138395
def versionString(version):
    
    ver = list(map(str, version))
    numbers, rest = ver[:2 if ver[2] == '0' else 3], ver[3:]
    return '.'.join(numbers) + '-'.join(rest)
63556
def version_str(version):
    
    if isinstance(version, str):
        return version
    elif isinstance(version, tuple):
        return '.'.join([str(int(x)) for x in version])
    else:
        raise ValueError("Invalid version: %s" % version)
1156560
def find_any_valid_version(self):  # type: () -> str
        
        versions = self.all_current_versions()

        if not versions and not self.force_init:
            raise JiggleVersionException(
                "Have no versions to work with, failed to find any. Include --init to start out at 0.1.0"
            )

        if not versions and self.force_init:
            versions = {"force_init": "0.1.0"}

        if len(versions) > 1:
            if not self.all_versions_equal(versions):
                if not self.all_versions_equal(versions):
                    almost_same = self.almost_the_same_version(
                        [x for x in versions.values()]
                    )
                    if almost_same:
                        # TODO: disable with strict option
                        logger.warning(
                            "Version very by a patch level, will use greater."
                        )
                        return unicode(almost_same)

        if not versions.keys():
            raise JiggleVersionException("Noooo! Must find a value" + unicode(versions))
        return unicode(first_value_in_dict(versions))
282599
def version(self, version_str: str) -> None:
        
        ver = []
        for i in version_str.split('.'):
            ver.append(int(i))
            self.filter_negatives(int(i))
        self._major, self._minor, self._patch = ver[0], ver[1], ver[2]
300587
def compare_version(self, version_string, op):
        """"""
        from pkg_resources import parse_version
        from monty.operator import operator_from_str
        op = operator_from_str(op)
        return op(parse_version(self.version), parse_version(version_string))
1156267
def check_has_version(self, api):
        ''''''
        if not hasattr(api, 'version'):
            msg = 'The Api class "{}" lacks a `version` attribute.'
            return [msg.format(api.__name__)]
751601
function validVersion(version, spec) {
  // Normalize route versions
  var test = spec.versions || [spec.version]

  // Check for direct version match
  if (~test.indexOf(version)) {
    return true
  }

  // Use semver and attempt to match on supplied version
  return !!test.filter(function(v) {
    return semver.satisfies(v, version)
  }).length
}
478300
def _check_version(self, config):
        
        try:
            self.file_version = config.get(
                escape_for_ini('keyring-setting'),
                escape_for_ini('version'),
            )
        except (configparser.NoSectionError, configparser.NoOptionError):
            return False
        return True
693136
def check_version(version_)
      v = version
      f = false
      if v.kind_of?(Hash) && v.include?("version") &&
          v['version'] >= "#{version_}" then
	f = true
      end

      [f, v['version']]
    end
1300819
def replace_version_tag(self):
        """"""
        version_tag = self.arguments.get('<version>')
        special_keywords = ['current', 'latest']
        if version_tag in special_keywords:
            logger.error("releasing version '{}' is disallowed. Did you mean 'version upload'?".format(version_tag))
            raise SystemExit(1)
        placeholders = dict(major=0, minor=1, trivial=2)
        placeholder = placeholders.get(version_tag)
        if placeholder is None:
            return version_tag
        current_version = self.get_git_describe().lstrip('v')
        version_numbers = current_version.split('-')[0].split('.')
        version_numbers = [int(item) for item in version_numbers]
        version_numbers = version_numbers[:placeholder + 1]
        while len(version_numbers) < 3:
            version_numbers.append(0)
        version_numbers[placeholder] += 1
        return '.'.join([str(item) for item in version_numbers[:2 if placeholder < 2 else 3]])
570305
def get_version():
    """"""
    proc = subprocess.Popen(
        ("git", "describe", "--tag", "--always"), 
        stdout=subprocess.PIPE, stderr=subprocess.STDOUT
    )
    output, _ = proc.communicate()
    result = output.decode("utf-8").strip()
    if proc.returncode != 0:
        sys.stderr.write(
            ">>> Git Describe Error:\n    " +
            result
        )
        return "1+unknown"
    split = result.split("-", 1)
    version = "+".join(split).replace("-", ".")

    if len(split) > 1:
        sys.stderr.write(
            ">>> Please verify the commit tag:\n    " +
            version + "\n"
        )
    return version
831909
def tag(version, params):
        
        cmd = ['git', 'tag', '-a', '-m', 'v%s' % version, str(version)]
        if params:
            cmd.extend(params)

        return cmd
1153199
def is_version(string)
      return false if string === false || string === true || string.nil?
      string.to_s.match(/^\d+[\d\.a-zA-Z\-_~]*/)
    end
478970
def find_version():
    """"""
    version_file = read_file('__init__.py')
    version_match = re.search(r'^__version__ = ["\']([^"\']*)["\']',
                              version_file, re.M)
    if version_match:
        return version_match.group(1)
    raise RuntimeError('Unable to find version string.')
436495
def extractVersion(string, default='?'):
    
    return extract(VERSION_PATTERN, string, condense=True, default=default,
                   one=True)