當前位置: 首頁>>代碼示例>>Java>>正文


Java GHRateLimit類代碼示例

本文整理匯總了Java中org.kohsuke.github.GHRateLimit的典型用法代碼示例。如果您正苦於以下問題:Java GHRateLimit類的具體用法?Java GHRateLimit怎麽用?Java GHRateLimit使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


GHRateLimit類屬於org.kohsuke.github包,在下文中一共展示了GHRateLimit類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: readyToBuildCauses

import org.kohsuke.github.GHRateLimit; //導入依賴的package包/類
/**
 * @return list of causes for scheduling branch builds.
 */
private List<GitHubBranchCause> readyToBuildCauses(GitHubBranchRepository localRepository,
                                                   LoggingTaskListenerWrapper listener,
                                                   @Nullable String requestedBranch) {
    try {
        GitHub github = getRepoProvider().getGitHub(this);
        GHRateLimit rateLimitBefore = github.getRateLimit();
        listener.debug("GitHub rate limit before check: {}", rateLimitBefore);

        // get local and remote list of branches
        GHRepository remoteRepo = getRemoteRepository();
        Set<GHBranch> remoteBranches = branchesToCheck(requestedBranch, remoteRepo, localRepository);

        List<GitHubBranchCause> causes = checkBranches(remoteBranches, localRepository, listener);

        /*
         * update details about the local repo after the causes are determined as they expect
         * new branches to not be found in the local details
         */
        updateLocalRepository(requestedBranch, remoteBranches, localRepository);
        saveIfSkipFirstRun();

        GHRateLimit rateLimitAfter = github.getRateLimit();
        int consumed = rateLimitBefore.remaining - rateLimitAfter.remaining;
        LOG.info("GitHub rate limit after check {}: {}, consumed: {}, checked branches: {}",
                localRepository.getFullName(), rateLimitAfter, consumed, remoteBranches.size());

        return causes;
    } catch (IOException e) {
        listener.error("Can't get build causes: '{}'", e);
        return emptyList();
    }
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:36,代碼來源:GitHubBranchTrigger.java

示例2: readyToBuildCauses

import org.kohsuke.github.GHRateLimit; //導入依賴的package包/類
/**
 * runs check of local (last) Repository state (list of PRs) vs current remote state
 * - local state store only last open PRs
 * - if last open PR <-> now closed -> should trigger only when ClosePREvent exist
 * - last open PR <-> now changed -> trigger only
 * - special comment in PR -> trigger
 *
 * @param localRepository persisted data to compare with remote state
 * @param listener        logger to write to console and to polling log
 * @param prNumber        pull request number to fetch only required num. Can be null
 * @return causes which ready to be converted to job-starts. One cause per repo.
 */
private List<GitHubPRCause> readyToBuildCauses(@Nonnull GitHubPRRepository localRepository,
                                               @Nonnull LoggingTaskListenerWrapper listener,
                                               @Nullable Integer prNumber) {
    try {
        GitHub github = getRepoProvider().getGitHub(this);

        GHRateLimit rateLimitBefore = github.getRateLimit();
        listener.debug("GitHub rate limit before check: {}", rateLimitBefore);

        // get local and remote list of PRs
        //FIXME HiddenField: 'remoteRepository' hides a field? renamed to `remoteRepo`
        GHRepository remoteRepo = getRemoteRepository();
        Set<GHPullRequest> remotePulls = pullRequestsToCheck(prNumber, remoteRepo, localRepository);

        Set<GHPullRequest> prepared = from(remotePulls)
                .filter(badState(localRepository, listener))
                .filter(notUpdated(localRepository, listener))
                .toSet();

        List<GitHubPRCause> causes = from(prepared)
                .filter(and(
                        ifSkippedFirstRun(listener, isSkipFirstRun()),
                        withBranchRestriction(listener, getBranchRestriction()),
                        withUserRestriction(listener, getUserRestriction())
                ))
                .transform(toGitHubPRCause(localRepository, listener, this))
                .filter(notNull())
                .toList();

        LOGGER.trace("Causes count for {}: {}", localRepository.getFullName(), causes.size());

        // refresh all PRs because user may add events that may trigger unexpected builds.
        from(remotePulls).transform(updateLocalRepo(localRepository)).toSet();

        saveIfSkipFirstRun();

        GHRateLimit rateLimitAfter = github.getRateLimit();
        int consumed = rateLimitBefore.remaining - rateLimitAfter.remaining;
        LOGGER.info("GitHub rate limit after check {}: {}, consumed: {}, checked PRs: {}",
                localRepository.getFullName(), rateLimitAfter, consumed, remotePulls.size());

        return causes;
    } catch (IOException e) {
        listener.error("Can't get build causes: ", e);
        return emptyList();
    }
}
 
開發者ID:KostyaSha,項目名稱:github-integration-plugin,代碼行數:60,代碼來源:GitHubPRTrigger.java


注:本文中的org.kohsuke.github.GHRateLimit類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。