当前位置: 首页>>代码示例>>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;未经允许,请勿转载。