# -*- coding: utf-8 -*-
"""
github3.repos.tag
=================

This module contains the RepoTag object for GitHub's tag API.

"""
from __future__ import unicode_literals

from ..models import GitHubCore


class RepoTag(GitHubCore):
    """The :class:`RepoTag <RepoTag>` object. This stores the information
    representing a tag that was created on a repository.

    See also: http://developer.github.com/v3/repos/#list-tags
    """
    def _update_attributes(self, tag):
        #: Name of the tag.
        self.name = self._get_attribute(tag, 'name')

        #: URL for the GitHub generated zipball associated with the tag.
        self.zipball_url = self._get_attribute(tag, 'zipball_url')

        #: URL for the GitHub generated tarball associated with the tag.
        self.tarball_url = self._get_attribute(tag, 'tarball_url')

        #: Dictionary containing the SHA and URL of the commit.
        self.commit = self._get_attribute(tag, 'commit', {})

    def _repr(self):
        return '<Repository Tag [{0}]>'.format(self)

    def __str__(self):
        return self.name

# -*- coding: utf-8 -*-
"""This module contains the RepoTag object for GitHub's tag API."""
from __future__ import unicode_literals

from . import commit
from .. import models


class RepoTag(models.GitHubCore):
    """Representation of a tag made on a GitHub repository.

    .. note::

        This is distinct from :class:`~github3.git.Tag`. This object
        has information specific to a tag on a *GitHub* repository.
        That includes URLs to the tarball and zipball files auto-generated
        by GitHub.

    See also: http://developer.github.com/v3/repos/#list-tags

    This object has the following attributes:

    .. attribute:: commit

        .. versionchanged:: 1.0.0

            This attribute used to be a two item dictionary.

        A :class:`~github3.repos.commit.MiniCommit` object representing the
        commit this tag references.

    .. attribute:: name

        The name of this tag, e.g., ``v1.0.0``.

    .. attribute:: tarball_url

        The URL for the tarball file generated by GitHub for this tag.

    .. attribute:: zipball_url

        The URL for the zipball file generated by GitHub for this tag.
    """

    def _update_attributes(self, tag):
        self.commit = commit.MiniCommit(tag['commit'], self)
        self.name = tag['name']
        self.tarball_url = tag['tarball_url']
        self.zipball_url = tag['zipball_url']

    def _repr(self):
        return '<Repository Tag [{0}]>'.format(self)

    def __str__(self):
        return self.name

Update github3.repos.tag for consistency