# Path: ghtools/exceptions.py
# class GithubAPIError(GithubError):
#     pass


import logging
import textwrap
from ghtools.exceptions import GithubAPIError
            payload = {'body': self._generate_comment_body(issue, comment)}
            self.dst.create_issue_comment(issue, payload)

        if should_close:
            self.dst.close_issue(issue)

    def _migrate_pull(self, pull):
        log.debug("Migrating %s to %s -> issues -> PR #%s", self.src, self.dst, pull['number'])

        if pull['head']['sha'] == pull['base']['sha']:
            log.warn('Skipping pull request migration: PR#%s', pull['number'])
            log.warn('Not creating PR with head.sha == base.sha (%s, %s)', pull['head']['sha'], pull['base']['sha'])
            return

        # Attempt to create a pull request on the basis of human-readable
        # refs first.
        try:
            self.dst.create_pull({'issue': pull['number'],
                                  'head': pull['head']['ref'],
                                  'base': pull['base']['ref']})
        except GithubAPIError:
            # Attempt to create a pull request with at least one
            # human-readable ref
            try:
                self.dst.create_pull({'issue': pull['number'],
                                      'head': pull['head']['sha'],
                                      'base': pull['base']['ref']})

            # Fall back to just creating the pull request with shas instead of
            # refs

# Path: ghtools/exceptions.py
# class GithubAPIError(GithubError):
#     pass


# Path: ghtools/migrators/issues.py
import logging
import textwrap
from ghtools.exceptions import GithubAPIError

            payload = {'body': self._generate_comment_body(issue, comment)}
            self.dst.create_issue_comment(issue, payload)

        if should_close:
            self.dst.close_issue(issue)

    def _migrate_pull(self, pull):
        log.debug("Migrating %s to %s -> issues -> PR #%s", self.src, self.dst, pull['number'])

        if pull['head']['sha'] == pull['base']['sha']:
            log.warn('Skipping pull request migration: PR#%s', pull['number'])
            log.warn('Not creating PR with head.sha == base.sha (%s, %s)', pull['head']['sha'], pull['base']['sha'])
            return

        # Attempt to create a pull request on the basis of human-readable
        # refs first.
        try:
            self.dst.create_pull({'issue': pull['number'],
                                  'head': pull['head']['ref'],
                                  'base': pull['base']['ref']})
        except GithubAPIError:
            # Attempt to create a pull request with at least one
            # human-readable ref
            try:
                self.dst.create_pull({'issue': pull['number'],
                                      'head': pull['head']['sha'],
                                      'base': pull['base']['ref']})

            # Fall back to just creating the pull request with shas instead of
            # refs

            except GithubAPIError: