Normalize a release to a version
320076
function normalizeVersion(release) {
    // Ignore draft
    if (release.draft) return null;

    var downloadCount = 0;
    var releasePlatforms = _.chain(release.assets)
        .map(function(asset) {
            var platform = platforms.detect(asset.name);
            if (!platform) return null;

            downloadCount = downloadCount + asset.download_count;
            return {
                id: String(asset.id),
                type: platform,
                filename: asset.name,
                size: asset.size,
                content_type: asset.content_type,
                raw: asset
            };
        })
        .compact()
        .value();

    return {
        tag: normalizeTag(release.tag_name).split('-')[0],
        channel: extractChannel(release.tag_name),
        notes: release.body || "",
        published_at: new Date(release.published_at),
        platforms: releasePlatforms
    };
}
1093815
def perform_release(context):
    """"""
    try:
        run_tests()

        if not context.skip_changelog:
            generate_changelog(context)

        increment_version(context)

        build_distributions(context)

        install_package(context)

        upload_package(context)

        install_from_pypi(context)

        publish(context)
    except Exception:
        log.exception('Error releasing')
189171
def normalizeFileFormatVersion(value):
    
    if not isinstance(value, int):
        raise TypeError("File format versions must be instances of "
                        ":ref:`type-int`, not %s."
                        % type(value).__name__)
    return value
951567
def unpack_version(version):
    """"""
    minor_version = version % VERSION_MULTIPLIER
    major_version = (version - minor_version) / VERSION_MULTIPLIER
    return (major_version, minor_version)
240968
def make_version(ref=None):
    """"""
    cmd = 'git describe --tags --abbrev=6 {}'.format(ref or '')
    with hide('commands'):
        version = local(cmd, capture=True).strip()
    if re.match('^v[0-9]', version):
        version = version[1:]
    # replacements to match semver.org build numbers
    if '-' in version:
        head, _, tail = version.partition('-')
        count, _, sha = tail.partition('-g')
        version = head + '+' + count + '-' + sha
    return version
213587
function cmpVersion(a, b) {
    "use strict";
    var i, cmp, len, re = /(\.0)+[^\.]*$/;
    function versionToString(version) {
        if (isObject(version)) {
            try {
                return [version.major, version.minor, version.patch].join('.');
            } catch (e) {}
        }
        return version;
    }
    a = versionToString(a);
    b = versionToString(b);
    a = (a + '').replace(re, '').split('.');
    b = (b + '').replace(re, '').split('.');
    len = Math.min(a.length, b.length);
    for (i = 0; i < len; i++) {
        cmp = parseInt(a[i], 10) - parseInt(b[i], 10);
        if (cmp !== 0) {
            return cmp;
        }
    }
    return a.length - b.length;
}
1279721
def bump_version(v: version.Version, level: str) -> str:
    """"""
    release: List[int] = list(v.release)
    stage: Optional[str]
    pre: Optional[int]
    stage, pre = v.pre if v.pre else (None, None)
    dev: Optional[int] = v.dev
    post: Optional[int] = v.post

    if level in ("major", "minor", "patch"):
        segments = 0
        if level == "major":
            # if the version code is in format of x.0.0, and pre/dev is not empty
            # do not increase the version number
            segments = 1
        elif level == "minor":
            # if the version code is in format of x.x.0, and pre/dev is not empty
            # do not increase the version number
            segments = 2
        elif level == "patch":
            # if the version code is in format of x.x.x, and pre/dev is not empty
            # do not increase the version number
            segments = 3
        if not any(release[segments:]) and (stage is not None or dev is not None):
            pass
        else:
            release[segments - 1] += 1
        release[segments:] = [0] * max(len(release) - segments, 0)
        stage = pre = post = dev = None
    elif level == "alpha":
        if stage is None:
            if dev is None:
                release[-1] += 1
            stage, pre = "a", 1
        elif stage > "a":
            release[-1] += 1
            stage, pre = "a", 1
        elif stage == "a":
            pre += 1
        post = dev = None
    elif level == "beta":
        if stage is None:
            if dev is None:
                release[-1] += 1
            stage, pre = "b", 1
        elif stage > "b":
            release[-1] += 1
            stage, pre = "b", 1
        elif stage == "b":
            pre += 1
        elif stage < "b":
            pre = 1
            stage = "b"
        post = dev = None
    elif level == "post":
        if post is not None:
            post += 1
        else:
            post = 1
        dev = None
    elif level == "dev":
        if dev is not None:
            dev += 1
        else:
            if stage:
                pre += 1
            else:
                release[-1] += 1
            dev = 1

    ver = ".".join(str(i) for i in release)
    if stage is not None:
        ver += f"{stage}{pre}"
    if post is not None:
        ver += f".post{post}"
    if dev is not None:
        ver += f".dev{dev}"

    return ver
549504
def EnsureSConsVersion(self, major, minor, revision=0):
        """"""
        # split string to avoid replacement during build process
        if SCons.__version__ == '__' + 'VERSION__':
            SCons.Warnings.warn(SCons.Warnings.DevelopmentVersionWarning,
                "EnsureSConsVersion is ignored for development version")
            return
        scons_ver = self._get_major_minor_revision(SCons.__version__)
        if scons_ver < (major, minor, revision):
            if revision:
                scons_ver_string = '%d.%d.%d' % (major, minor, revision)
            else:
                scons_ver_string = '%d.%d' % (major, minor)
            print("SCons %s or greater required, but you have SCons %s" % \
                  (scons_ver_string, SCons.__version__))
            sys.exit(2)
257102
def _prepare_version(self):
        """"""
        if config.VERSION not in self._config:
            self._config[config.VERSION] = __version__
261553
private String extractNumericVersion(Collection<String> versionStrings) {
        if (versionStrings == null) {
            return "";
        }
        for (String value : versionStrings) {
            String releaseValue = calculateReleaseVersion(value);
            if (!releaseValue.equals(value)) {
                return releaseValue;
            }
        }
        return "";
    }
1309603
def version():
    """"""
    with open(os.path.join('curtsies', '__init__.py')) as input_file:
        for line in input_file:
            if line.startswith('__version__'):
                return ast.parse(line).body[0].value.s
610836
function normVersion(tag) {
    var parts = new semver.SemVer(tag);
    var prerelease = "";

    if (parts.prerelease && parts.prerelease.length > 0) {
        prerelease = hashPrerelease(parts.prerelease);
    }

    return [
        parts.major,
        parts.minor,
        parts.patch
    ].join('.') + (prerelease? '.'+prerelease : '');
}
596031
def safe_version(version):
    
    try:
        # normalize the version
        return str(packaging.version.Version(version))
    except packaging.version.InvalidVersion:
        version = version.replace(' ', '.')
        return re.sub('[^A-Za-z0-9.]+', '-', version)
1165376
def _parse_version(self, value):
        
        version = self._parse_file(value)

        if version != value:
            version = version.strip()
            # Be strict about versions loaded from file because it's easy to
            # accidentally include newlines and other unintended content
            if isinstance(parse(version), LegacyVersion):
                tmpl = (
                    'Version loaded from {value} does not '
                    'comply with PEP 440: {version}'
                )
                raise DistutilsOptionError(tmpl.format(**locals()))

            return version

        version = self._parse_attr(value, self.package_dir)

        if callable(version):
            version = version()

        if not isinstance(version, string_types):
            if hasattr(version, '__iter__'):
                version = '.'.join(map(str, version))
            else:
                version = '%s' % version

        return version
235577
def cleanup_version(version):
    """"""
    for w in WRONG_IN_VERSION:
        if version.find(w) != -1:
            logger.debug("Version indicates development: %s.", version)
            version = version[:version.find(w)].strip()
            logger.debug("Removing debug indicators: %r", version)
        version = version.rstrip('.')  # 1.0.dev0 -> 1.0. -> 1.0
    return version
354259
function parseVersion(versionString) {
  const [release, prerelease] = versionString.split('-')
  const splitRelease = release.split('.').map(number => parseInt(number, 10))

  return {
    major: splitRelease[0],
    minor: splitRelease[1],
    patch: splitRelease[2],
    prerelease: prerelease || '',
    raw: versionString
  }
}
1341584
def get_version(package, url_pattern=URL_PATTERN):
    """"""
    req = requests.get(url_pattern.format(package=package))
    version = parse('0')
    if req.status_code == requests.codes.ok:
        # j = json.loads(req.text.encode(req.encoding))
        j = req.json()
        releases = j.get('releases', [])
        for release in releases:
            ver = parse(release)
            if not ver.is_prerelease:
                version = max(version, ver)
    return version