当前位置: 首页>>代码示例>>Java>>正文


Java GHPullRequest类代码示例

本文整理汇总了Java中org.kohsuke.github.GHPullRequest的典型用法代码示例。如果您正苦于以下问题:Java GHPullRequest类的具体用法?Java GHPullRequest怎么用?Java GHPullRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GHPullRequest类属于org.kohsuke.github包,在下文中一共展示了GHPullRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loadCommandsFromPullRequest

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
/**
 * Lets load the old command context from comments on the PullRequest so that we can re-run a command to rebase things.
 */
protected CompositeCommand loadCommandsFromPullRequest(CommandContext context, GHRepository ghRepository, GHPullRequest pullRequest) throws IOException {
    List<GHIssueComment> comments = pullRequest.getComments();
    String lastCommand = null;
    for (GHIssueComment comment : comments) {
        String command = updateBotCommentCommand(context, comment);
        if (command != null) {
            lastCommand = command;
        }
    }
    if (lastCommand == null) {
        context.warn(LOG, "No UpdateBot comment found on pull request " + pullRequest.getHtmlUrl() + " so cannot rebase!");
        return null;
    }
    return parseUpdateBotCommandComment(context, lastCommand);
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:19,代码来源:UpdatePullRequests.java

示例2: isMergeable

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
public static boolean isMergeable(GHPullRequest pullRequest) throws IOException {
    boolean canMerge = false;
    Boolean mergeable = pullRequest.getMergeable();
    GHPullRequest single = null;
    if (mergeable == null) {
        single = pullRequest.getRepository().getPullRequest(pullRequest.getNumber());
        mergeable = single.getMergeable();
    }
    if (mergeable == null) {
        LOG.warn("Mergeable flag is still null on pull request " + pullRequest.getHtmlUrl() + " assuming its still mergable. Probably a caching issue and this flag may appear again later");
        return true;
    }
    if (mergeable != null && mergeable.booleanValue()) {
        canMerge = true;
    }
    return canMerge;
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:18,代码来源:GitHubHelpers.java

示例3: waitForPullRequestToHaveMergable

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
public static Boolean waitForPullRequestToHaveMergable(GHPullRequest pullRequest, long sleepMS, long maximumTimeMS) throws IOException {
    long end = System.currentTimeMillis() + maximumTimeMS;
    while (true) {
        Boolean mergeable = pullRequest.getMergeable();
        if (mergeable == null) {
            GHRepository repository = pullRequest.getRepository();
            int number = pullRequest.getNumber();
            pullRequest = repository.getPullRequest(number);
            mergeable = pullRequest.getMergeable();
        }
        if (mergeable != null) {
            return mergeable;
        }
        if (System.currentTimeMillis() > end) {
            return null;
        }
        try {
            Thread.sleep(sleepMS);
        } catch (InterruptedException e) {
            // ignore
        }
    }
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:24,代码来源:GitHubHelpers.java

示例4: mapPatchPositionsToLines

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
/**
 * GitHub expect review comments to be added on "patch lines" (aka position) but not on file lines.
 * So we have to iterate over each patch and compute corresponding file line in order to later map issues to the correct position.
 * @return Map File path -> Line -> Position
 */
private Map<String, Map<Integer, Integer>> mapPatchPositionsToLines(GHPullRequest pr) throws IOException {
  Map<String, Map<Integer, Integer>> result = new HashMap<>();
  for (GHPullRequestFileDetail file : pr.listFiles()) {
    Map<Integer, Integer> patchLocationMapping = new HashMap<>();
    result.put(file.getFilename(), patchLocationMapping);
    if (config.tryReportIssuesInline()) {
      String patch = file.getPatch();
      if (patch == null) {
        continue;
      }
      processPatch(patchLocationMapping, patch);
    }
  }
  return result;
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:21,代码来源:PullRequestFacade.java

示例5: testGetGithubUrl

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
@Test
public void testGetGithubUrl() throws Exception {

  File gitBasedir = temp.newFolder();

  PullRequestFacade facade = new PullRequestFacade(mock(GitHubPluginConfiguration.class));
  facade.setGitBaseDir(gitBasedir);
  GHRepository ghRepo = mock(GHRepository.class);
  when(ghRepo.getHtmlUrl()).thenReturn(new URL("https://github.com/SonarSource/sonar-java"));
  facade.setGhRepo(ghRepo);
  GHPullRequest pr = mock(GHPullRequest.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS));
  when(pr.getHead().getSha()).thenReturn("abc123");
  facade.setPr(pr);
  InputPath inputPath = mock(InputPath.class);
  when(inputPath.file()).thenReturn(new File(gitBasedir, "src/main/with space/Foo.java"));
  assertThat(facade.getGithubUrl(inputPath, 10).toString()).isEqualTo("https://github.com/SonarSource/sonar-java/blob/abc123/src/main/with%20space/Foo.java#L10");
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:18,代码来源:PullRequestFacadeTest.java

示例6: testGetCommitStatusForContextWithOneCorrectStatus

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
@Test
public void testGetCommitStatusForContextWithOneCorrectStatus() throws IOException {
  PullRequestFacade facade = new PullRequestFacade(mock(GitHubPluginConfiguration.class));
  GHRepository ghRepo = mock(GHRepository.class);
  PagedIterable<GHCommitStatus> ghCommitStatuses = Mockito.mock(PagedIterable.class);
  List<GHCommitStatus> ghCommitStatusesList = new ArrayList<>();
  GHCommitStatus ghCommitStatusGHPRHContext = Mockito.mock(GHCommitStatus.class);
  ghCommitStatusesList.add(ghCommitStatusGHPRHContext);
  GHPullRequest pr = mock(GHPullRequest.class, withSettings().defaultAnswer(RETURNS_DEEP_STUBS));
  when(pr.getRepository()).thenReturn(ghRepo);
  when(pr.getHead().getSha()).thenReturn("abc123");
  when(ghRepo.listCommitStatuses(pr.getHead().getSha())).thenReturn(ghCommitStatuses);
  when(ghCommitStatuses.asList()).thenReturn(ghCommitStatusesList);
  when(ghCommitStatusGHPRHContext.getContext()).thenReturn(PullRequestFacade.COMMIT_CONTEXT);
  assertThat(facade.getCommitStatusForContext(pr, PullRequestFacade.COMMIT_CONTEXT).getContext()).isEqualTo(PullRequestFacade.COMMIT_CONTEXT);
}
 
开发者ID:SonarSource,项目名称:sonar-github,代码行数:17,代码来源:PullRequestFacadeTest.java

示例7: getPullRequests

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static List<Integer> getPullRequests(GHRepository repo, GHMilestone milestone, Calendar calendar) {
    return (List<Integer>) execute(TimeTrackerLabel.GET_PULL_REQUESTS, () -> {
        List<Integer> pullRequests = new ArrayList<>();

        for (GHPullRequest pullRequest : repo.getPullRequests(CLOSED)) {
            if (!matchesMilestone(pullRequest, milestone)) {
                continue;
            }
            if (isDebug()) {
                printDebugOutput(calendar, pullRequest);
            } else {
                System.out.print('.');
            }
            pullRequests.add(pullRequest.getNumber());
        }
        if (!isDebug()) {
            System.out.println();
        }
        return pullRequests;
    });
}
 
开发者ID:hazelcast,项目名称:hazelcast-qa,代码行数:23,代码来源:GitHubUtils.java

示例8: matchesMilestone

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
static boolean matchesMilestone(GHPullRequest pullRequest, GHMilestone milestone) {
    if (milestone == MERGED_MILESTONE) {
        // we don't care if the PR has a milestone at all
        return isMerged(pullRequest);
    }
    GHMilestone prMilestone = pullRequest.getMilestone();
    if (milestone == ALL_MILESTONE) {
        // we don't care which milestone the PR has
        return (prMilestone != null && isMerged(pullRequest));
    }
    if (milestone == NO_MILESTONE) {
        // the PR should not have a milestone
        return (prMilestone == null && isMerged(pullRequest));
    }
    // the PR has to have the wanted milestone
    return (prMilestone != null && prMilestone.getId() == milestone.getId() && isMerged(pullRequest));
}
 
开发者ID:hazelcast,项目名称:hazelcast-qa,代码行数:18,代码来源:GitHubUtils.java

示例9: createPullRequestsList

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
/**
 * Create DTO object of GitHub pull-requests collection from given pull-requests
 *
 * @param ghPullRequestsList collection of pull-requests from kohsuke GitHub library
 * @return DTO object
 * @throws IOException
 */
public GitHubPullRequestList createPullRequestsList(
    PagedIterable<GHPullRequest> ghPullRequestsList) throws IOException {
  GitHubPullRequestList gitHubPullRequestList =
      DtoFactory.getInstance().createDto(GitHubPullRequestList.class);

  List<GitHubPullRequest> dtoPullRequestsList = new ArrayList<>();

  for (GHPullRequest ghPullRequest : ghPullRequestsList) {
    dtoPullRequestsList.add(createPullRequest(ghPullRequest));
  }

  gitHubPullRequestList.setPullRequests(dtoPullRequestsList);

  return gitHubPullRequestList;
}
 
开发者ID:eclipse,项目名称:che,代码行数:23,代码来源:GitHubDTOFactory.java

示例10: createPullRequest

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
/**
 * Create DTO object of GitHub pull-request from given pull-request
 *
 * @param ghPullRequest pull-request from kohsuke GitHub library
 * @return DTO object
 * @throws IOException
 */
public GitHubPullRequest createPullRequest(GHPullRequest ghPullRequest) throws IOException {
  GitHubPullRequest dtoPullRequest = DtoFactory.getInstance().createDto(GitHubPullRequest.class);

  dtoPullRequest.setId(String.valueOf(ghPullRequest.getId()));
  dtoPullRequest.setUrl(String.valueOf(ghPullRequest.getUrl()));
  dtoPullRequest.setHtmlUrl(String.valueOf(ghPullRequest.getHtmlUrl()));
  dtoPullRequest.setNumber(String.valueOf(ghPullRequest.getNumber()));
  dtoPullRequest.setState(ghPullRequest.getState().toString());
  dtoPullRequest.setHead(createPullRequestHead(ghPullRequest.getHead()));
  dtoPullRequest.setMerged(ghPullRequest.isMerged());
  dtoPullRequest.setBody(ghPullRequest.getBody());
  dtoPullRequest.setTitle(ghPullRequest.getTitle());
  if (ghPullRequest.getMergedBy() != null) {
    dtoPullRequest.setMergedBy(createUser(ghPullRequest.getMergedBy()));
  }
  if (ghPullRequest.getMergeable() != null) {
    dtoPullRequest.setMergeable(ghPullRequest.getMergeable());
  }

  return dtoPullRequest;
}
 
开发者ID:eclipse,项目名称:che,代码行数:29,代码来源:GitHubDTOFactory.java

示例11: createPullRequest

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
@POST
@Path("pullrequest/{user}/{repository}")
@Produces(MediaType.APPLICATION_JSON)
public GitHubPullRequest createPullRequest(
    @PathParam("user") String user,
    @PathParam("repository") String repository,
    @HeaderParam(AUTH_HEADER_NAME) String oauthToken,
    GitHubPullRequestCreationInput input)
    throws ApiException {
  try {
    GHPullRequest pullRequest =
        gitHubFactory
            .oauthConnect(oauthToken)
            .getUser(user)
            .getRepository(repository)
            .createPullRequest(
                input.getTitle(), input.getHead(), input.getBase(), input.getBody());
    return gitHubDTOFactory.createPullRequest(pullRequest);
  } catch (Exception e) {
    if (!e.getMessage().contains("No commits between master and master")) {
      LOG.error("Creating  pull request fail", e);
    }
    throw new ServerException(e.getMessage());
  }
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:GitHubService.java

示例12: isBranchBuildAllowed

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
public boolean isBranchBuildAllowed(GHPullRequest remotePR) {
    String branchName = remotePR.getBase().getRef();
    //if allowed branch list is empty, it's allowed to build any branch
    boolean isAllowed = targetBranchList.isEmpty();

    for (String branch : targetBranchList) {
        //if branch name matches to pattern, allow build
        isAllowed = Pattern.compile(branch).matcher(branchName).matches();
        if (isAllowed) {
            break;
        }
    }

    LOGGER.trace("Target branch {} is {} in our whitelist of target branches", branchName,
            (isAllowed ? "" : "not "));
    return isAllowed;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:18,代码来源:GitHubPRBranchRestriction.java

示例13: pullRequestsToCheck

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
/**
 * @return remote pull requests for future analysing.
 */
private static Set<GHPullRequest> pullRequestsToCheck(@Nullable Integer prNumber,
                                                      @Nonnull GHRepository remoteRepo,
                                                      @Nonnull GitHubPRRepository localRepo) throws IOException {
    if (prNumber != null) {
        return execute(() -> singleton(remoteRepo.getPullRequest(prNumber)));
    } else {
        List<GHPullRequest> remotePulls = execute(() -> remoteRepo.getPullRequests(GHIssueState.OPEN));

        Set<Integer> remotePRNums = from(remotePulls).transform(extractPRNumber()).toSet();

        return from(localRepo.getPulls().keySet())
                // add PRs that was closed on remote
                .filter(not(in(remotePRNums)))
                .transform(fetchRemotePR(remoteRepo))
                .filter(notNull())
                .append(remotePulls)
                .toSet();
    }
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:23,代码来源:GitHubPRTrigger.java

示例14: checkComment

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
private GitHubPRCause checkComment(GHIssueComment issueComment,
                                   GitHubPRUserRestriction userRestriction,
                                   GHPullRequest remotePR,
                                   TaskListener listener) {
    GitHubPRCause cause = null;
    try {
        String body = issueComment.getBody();

        if (isNull(userRestriction) || userRestriction.isWhitelisted(issueComment.getUser())) {
            final Matcher matcher = Pattern.compile(comment).matcher(body);
            if (matcher.matches()) {
                listener.getLogger().println(DISPLAY_NAME + ": matching comment " + body);
                LOG.trace("Event matches comment '{}'", body);
                cause = new GitHubPRCause(remotePR, "Comment matches to criteria.", false);
                cause.withCommentBody(body);
                if (matcher.groupCount() > 0) {
                    cause.withCommentBodyMatch(matcher.group(1));
                }
            }
        }
    } catch (IOException ex) {
        LOG.error("Couldn't check comment #{}, skipping it.", issueComment.getId(), ex);
    }
    return cause;
}
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:26,代码来源:GitHubPRCommentEvent.java

示例15: check

import org.kohsuke.github.GHPullRequest; //导入依赖的package包/类
@Override
    public GitHubPRCause check(GitHubPRTrigger gitHubPRTrigger, GHPullRequest remotePR,
                               GitHubPRPullRequest localPR, TaskListener listener) throws IOException {
        if (remotePR.getState().equals(GHIssueState.CLOSED)) {
            //TODO check whether push to closed allowed?
            return null; // already closed, nothing to check
        }

        if (isNull(localPR)) { // new
            return null; // not interesting for this event
        }

        GitHubPRCause cause = null;

        GHCommitPointer head = remotePR.getHead();
        if (!localPR.getHeadSha().equals(head.getSha())) {
            LOGGER.debug("New commit. Sha: {} => {}", localPR.getHeadSha(), head.getSha());
            final PrintStream logger = listener.getLogger();
            logger.println(this.getClass().getSimpleName() + ": new commit found, sha " + head.getSha());
//            GHUser user = head.getUser();
            cause = new GitHubPRCause(remotePR, DISPLAY_NAME, false);
        }

        return cause;
    }
 
开发者ID:KostyaSha,项目名称:github-integration-plugin,代码行数:26,代码来源:GitHubPRCommitEvent.java


注:本文中的org.kohsuke.github.GHPullRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。