コード例 #1
0
ファイル: versionChecker.py プロジェクト: jwdv22/Sick-Beard
    def _check_github_for_update(self):
        """
        Uses pygithub to ask github if there is a newer version that the provided
        commit hash. If there is a newer version it sets Sick Beard's version text.

        commit_hash: hash that we're checking against
        """

        self._num_commits_behind = 0
        self._newest_commit_hash = None

        gh = github.GitHub()

        # find newest commit
        for curCommit in gh.commits('midgetspy', 'Sick-Beard', self.branch):
            if not self._newest_commit_hash:
                self._newest_commit_hash = curCommit['sha']
                if not self._cur_commit_hash:
                    break

            if curCommit['sha'] == self._cur_commit_hash:
                break

            self._num_commits_behind += 1

        logger.log(u"newest: "+str(self._newest_commit_hash)+" and current: "+str(self._cur_commit_hash)+" and num_commits: "+str(self._num_commits_behind), logger.DEBUG)
コード例 #2
0
    def _check_github_for_update(self):
        """
        Uses pygithub to ask github if there is a newer version that the provided
        commit hash. If there is a newer version it sets Sick Beard's version text.

        commit_hash: hash that we're checking against
        """

        self._num_commits_behind = 0
        self._newest_commit_hash = None

        gh = github.GitHub(self.github_repo_user, self.github_repo,
                           self.branch)

        # try to get newest commit hash and commits behind directly by comparing branch and current commit
        if self._cur_commit_hash:
            branch_compared = gh.compare(base=self.branch,
                                         head=self._cur_commit_hash)

            if 'base_commit' in branch_compared:
                self._newest_commit_hash = branch_compared['base_commit'][
                    'sha']

            if 'behind_by' in branch_compared:
                self._num_commits_behind = int(branch_compared['behind_by'])

        # fall back and iterate over last 100 (items per page in gh_api) commits
        if not self._newest_commit_hash:

            for curCommit in gh.commits():
                if not self._newest_commit_hash:
                    self._newest_commit_hash = curCommit['sha']
                    if not self._cur_commit_hash:
                        break

                if curCommit['sha'] == self._cur_commit_hash:
                    break

                # when _cur_commit_hash doesn't match anything _num_commits_behind == 100
                self._num_commits_behind += 1

        logger.log(
            u"cur_commit = " + str(self._cur_commit_hash) +
            u", newest_commit = " + str(self._newest_commit_hash) +
            u", num_commits_behind = " + str(self._num_commits_behind),
            logger.DEBUG)
コード例 #3
0
 def list_remote_branches(self):
     gh = github.GitHub(self.github_repo_user, self.github_repo, self.branch)
     return [x.name for x in gh.branches() if x]
コード例 #4
0
ファイル: versionChecker.py プロジェクト: sendas/SickGear
 def list_remote_branches(self):
     gh = github.GitHub(self.github_repo_user, self.github_repo, self.branch)
     return [x['name'] for x in gh.branches() if x and 'name' in x]
コード例 #5
0
ファイル: version_checker.py プロジェクト: whiteyw80/SickGear
 def list_remote_pulls(self):
     gh = github.GitHub(self.github_repo_user, self.github_repo,
                        self.branch)
     return gh.pull_requests()