Determine a version is a local git tag name or not.

    :param version: A string containing the branch/tag/sha to be determined.
    :param debug: An optional bool to toggle debug output.
    :return: bool
166615
def _has_tag(version, debug=False):
    
    cmd = sh.git.bake('show-ref', '--verify', '--quiet',
                      "refs/tags/{}".format(version))
    try:
        util.run_command(cmd, debug=debug)
        return True
    except sh.ErrorReturnCode:
        return False
870818
def tag_to_version(tag, config=None):
    
    trace("tag", tag)

    if not config:
        config = Configuration()

    tagdict = _parse_version_tag(tag, config)
    if not isinstance(tagdict, dict) or not tagdict.get("version", None):
        warnings.warn("tag %r no version found" % (tag,))
        return None

    version = tagdict["version"]
    trace("version pre parse", version)

    if tagdict.get("suffix", ""):
        warnings.warn(
            "tag %r will be stripped of its suffix '%s'" % (tag, tagdict["suffix"])
        )

    if VERSION_CLASS is not None:
        version = pkg_parse_version(version)
        trace("version", repr(version))

    return version
1336641
def get_version():
        
        try:
            return check_output(
                "git describe --tags".split(" ")
                ).decode('utf-8').strip()
        except CalledProcessError:
            return check_output(
                "git rev-parse --short HEAD".split(" ")
                ).decode('utf-8').strip()
966176
def version(self):
        """"""
        if not self.__version:
            command = (self.name, '--version')
            logger.debug(command)
            stdout, _ = subprocess.Popen(
                command, stdout=subprocess.PIPE).communicate()
            version_output = str(stdout)
            match = re.search(self.version_patt, version_output)
            if match is None:
                raise ServersError(
                    'Could not determine version of %s from string: %s'
                    % (self.name, version_output))
            version_string = match.group('version')
            self.__version = tuple(map(int, version_string.split('.')))
        return self.__version
692505
def _get_version_from_git_tag(path):
    
    m = GIT_DESCRIBE_REGEX.match(_git_describe_tags(path) or '')
    if m is None:
        return None
    version, post_commit, hash = m.groups()
    return version if post_commit == '0' else "{0}.post{1}+{2}".format(version, post_commit, hash)
1230162
def format_version(version, build_number=None, build_tag=BUILD_TAG):
    
    formatted_version = ".".join(map(str, version))

    if build_number is not None:
        return "{formatted_version}-{build_tag}-{build_number}".format(**locals())
    
    return formatted_version
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
926941
def tag():
    """"""
    if check_unstaged():
        raise EnvironmentError('There are staged changes, abort.')
    with open(str(INIT_PATH)) as f:
        metadata = dict(re.findall("__([a-z]+)__ = '([^']+)'", f.read()))
    version = metadata['version']
    check_output(['git', 'tag', version, '-m', 'Release v{}'.format(version)])
191738
private boolean hasTag(String version) {
        for (final String string : Updater.NO_UPDATE_TAG) {
            if (version.contains(string)) {
                return true;
            }
        }
        return false;
    }
1164506
def last_git_release_tag(git_tags: str) -> str:
    
    semver_re = re.compile(r'[0-9]+\.[0-9]+\.[0-9]+$')
    str_ver = []
    for i in git_tags.split():
        if semver_re.search(i):
            str_ver.append(i)

    try:
        return str_ver[0]
    except IndexError:
        raise NoGitTagsException
748713
def get_version(cls, path, memo={}):
        
        if path not in memo:
            memo[path] = subprocess.check_output(
                "git describe --tags --dirty 2> /dev/null",
                shell=True, cwd=path).strip().decode("utf-8")

            v = re.search("-[0-9]+-", memo[path])
            if v is not None:
                # Replace -n- with -branchname-n-
                branch = r"-{0}-\1-".format(cls.get_branch(path))
                (memo[path], _) = re.subn("-([0-9]+)-", branch, memo[path], 1)

        return memo[path]
1166873
private boolean versionCheck(String title) {
        if (this.type != UpdateType.NO_VERSION_CHECK) {
            final String version = caller.getPluginVersion();
            final String remoteVersion = title; // Get the newest file's version number

            if (this.hasTag(version) || version.contains(remoteVersion)) {
                // We already have the latest version, or this build is tagged for no-update
                this.result = Updater.UpdateResult.NO_UPDATE;
                return false;
            }
        }
        return true;
    }
429415
def has_bug?(name, _options = {})
      unless self.respond_to?(:version) && version
        puts 'To test for the presence of a bug the object must implement an attribute'
        puts "called 'version' which returns the IP version represented by the the object."
        fail 'Version undefined!'
      end
      name = name.to_s.downcase.to_sym
      if bugs[name]
        bugs[name].present_on_version?(version)
      else
        false
      end
    end
304922
def _get_init_release_tag(self):
        
        self.init_version = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
                                      open(self.init_file, "r").read(),
                                      re.M).group(1)
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
71156
def tag(message):
    # type: () -> None
    
    release_ver = versioning.current()
    message = message or 'v{} release'.format(release_ver)

    with conf.within_proj_dir():
        log.info("Creating release tag")
        git.tag(
            author=git.latest_commit().author,
            name='v{}'.format(release_ver),
            message=message,
        )
550591
def get_git_version(cls):
        
        try:
            output = cls.run_git_shell('git version')
        except CalledProcessError:
            cls.LOG.warning("Unable to get Git version.")
            return None

        try:
            version = output.split()[2]
        except IndexError:
            cls.LOG.warning("Unable to parse Git version \"%s\".", output)
            return None

        try:
            return tuple(int(v) for v in version.split('.'))
        except ValueError:
            cls.LOG.warning("Unable to parse Git version \"%s\".", version)
            return None