'Update or create a repository from GitHub API response
:param fields: dictionary of response data from API
:param privacy: privacy level to support
:param organization: remote organization to associate with
:type organization: RemoteOrganization
:rtype: RemoteRepository'

def create_repository(self, fields, privacy=DEFAULT_PRIVACY_LEVEL, organization=None):

    if ((privacy == 'private') or ((fields['private'] is False) and (privacy == 'public'))):
        try:
            repo = RemoteRepository.objects.get(full_name=fields['full_name'], users=self.user, account=self.account)
        except RemoteRepository.DoesNotExist:
            repo = RemoteRepository.objects.create(full_name=fields['full_name'], account=self.account)
            repo.users.add(self.user)
        if (repo.organization and (repo.organization != organization)):
            log.debug('Not    importing    %s    because    mismatched    orgs', fields['name'])
            return None
        else:
            repo.organization = organization
        repo.name = fields['name']
        repo.description = fields['description']
        repo.ssh_url = fields['ssh_url']
        repo.html_url = fields['html_url']
        repo.private = fields['private']
        if repo.private:
            repo.clone_url = fields['ssh_url']
        else:
            repo.clone_url = fields['clone_url']
        repo.admin = fields.get('permissions', {}).get('admin', False)
        repo.vcs = 'git'
        repo.account = self.account
        repo.avatar_url = fields.get('owner', {}).get('avatar_url')
        repo.json = json.dumps(fields)
        repo.save()
        return repo
    else:
        log.debug('Not    importing    %s    because    mismatched    type', fields['name'])
