'Uses git commands to check if there is a newer version that the provided
commit hash. If there is a newer version it sets _num_commits_behind.'

def _check_github_for_update(self):

    self._num_commits_behind = 0
    self._num_commits_ahead = 0
    self.update_remote_origin()
    (output, errors_, exit_status) = self._run_git(self._git_path, u'fetch    {0}'.format(sickbeard.GIT_REMOTE))
    if (exit_status != 0):
        logger.log(u"Unable    to    contact    github,    can't    check    for    update", logger.WARNING)
        return
    (output, stderr_, exit_status) = self._run_git(self._git_path, u'branch    --set-upstream-to    {0}/{1}'.format(sickbeard.GIT_REMOTE, self.branch), False)
    if (exit_status != 0):
        self._run_git(self._git_path, u'branch    -u    {0}/{1}'.format(sickbeard.GIT_REMOTE, self.branch), False)
    (output, stderr_, exit_status) = self._run_git(self._git_path, u'rev-parse    --verify    --quiet    "@{upstream}"')
    if ((exit_status == 0) and output):
        cur_commit_hash = output.strip()
        if (not re.match(u'^[a-z0-9]+$', cur_commit_hash)):
            logger.log(u"Output    doesn't    look    like    a    hash,    not    using    it", logger.DEBUG)
            return
        else:
            self._newest_commit_hash = cur_commit_hash
    else:
        logger.log(u"git    didn't    return    newest    commit    hash", logger.DEBUG)
        return
    (output, stderr_, exit_status) = self._run_git(self._git_path, u'rev-list    --left-right    "@{upstream}"...HEAD')
    if ((exit_status == 0) and output):
        try:
            self._num_commits_behind = int(output.count(u'<'))
            self._num_commits_ahead = int(output.count(u'>'))
        except Exception:
            logger.log(u"git    didn't    return    numbers    for    behind    and    ahead,    not    using    it", logger.DEBUG)
            return
    logger.log(u'cur_commit    =    {0},    newest_commit    =    {1},    num_commits_behind    =    {2},    num_commits_ahead    =    {3}'.format(self._cur_commit_hash, self._newest_commit_hash, self._num_commits_behind, self._num_commits_ahead), logger.DEBUG)
