@public<EOL>def find_tag_by_name(repo, tag_name, safe=True):
tagfmt = '<STR_LIT>'.format(ref=tag_name)<EOL>try:<EOL><INDENT>ref = repo.get_git_ref(tagfmt)<EOL>if ref and ref.ref:<EOL><INDENT>return ref<EOL><DEDENT><DEDENT>except github.UnknownObjectException:<EOL><INDENT>if not safe:<EOL><INDENT>raise<EOL><DEDENT><DEDENT>return None<EOL>
Find tag by name in a github Repository

    Parameters
    ----------
    repo: :class:`github.Repository` instance

    tag_name: str
        Short name of tag (not a fully qualified ref).

    safe: bool, optional
        Defaults to `True`. When `True`, `None` is returned on failure. When
        `False`, an exception will be raised upon failure.

    Returns
    -------
    gh : :class:`github.GitRef` instance or `None`

    Raises
    ------
    github.UnknownObjectException
        If git tag name does not exist in repo.