@Override
  public IStatus performQuery(
      TaskRepository repository,
      IRepositoryQuery query,
      TaskDataCollector collector,
      ISynchronizationSession session,
      IProgressMonitor monitor) {
    IStatus result = Status.OK_STATUS;
    List<String> statuses = QueryUtils.getAttributes(IssueService.FILTER_STATE, query);

    monitor.beginTask(Messages.PullRequestConnector_TaskFetching, statuses.size());
    try {
      RepositoryId repo = getRepository(repository.getRepositoryUrl());

      GitHubClient client = IssueConnector.createClient(repository);
      PullRequestService service = new PullRequestService(client);
      IssueService commentService = new IssueService(client);

      for (String status : statuses) {
        List<PullRequest> pulls = service.getPullRequests(repo, status);

        // collect task data
        for (PullRequest pr : pulls) {
          pr = service.getPullRequest(repo, pr.getNumber());
          PullRequestComposite prComp = new PullRequestComposite();
          prComp.setRequest(pr);
          List<Comment> comments = null;
          if (pr.getComments() > 0)
            comments =
                commentService.getComments(
                    repo.getOwner(), repo.getName(), Integer.toString(pr.getNumber()));
          if (pr.getCommits() > 0) prComp.setCommits(service.getCommits(repo, pr.getNumber()));
          TaskData taskData =
              taskDataHandler.createTaskData(repository, monitor, repo, prComp, comments);
          collector.accept(taskData);
        }
        monitor.worked(1);
      }
    } catch (IOException e) {
      result = GitHub.createWrappedStatus(e);
    }

    monitor.done();
    return result;
  }
Esempio n. 2
0
 public Collection<PullRequest> getClosedPullRequests(final IRepositoryIdProvider repository) {
   Collection<PullRequest> pullrequests = null;
   try {
     pullrequests = service.getPullRequests(repository, IssueService.STATE_CLOSED);
   } catch (IOException e) {
     log.error(
         "IOException in getOpenPullRequests {} {}", new Object[] {repository.generateId(), e});
   }
   return pullrequests;
 }
  @Override
  public TaskData getTaskData(TaskRepository repository, String taskId, IProgressMonitor monitor)
      throws CoreException {
    RepositoryId repo = getRepository(repository.getRepositoryUrl());

    try {
      GitHubClient client = IssueConnector.createClient(repository);
      PullRequestService service = new PullRequestService(client);
      PullRequest pr = service.getPullRequest(repo, Integer.parseInt(taskId));
      PullRequestComposite prComp = new PullRequestComposite();
      prComp.setRequest(pr);
      IssueService commentService = new IssueService(client);
      List<Comment> comments = null;
      if (pr.getComments() > 0)
        comments = commentService.getComments(repo.getOwner(), repo.getName(), taskId);
      if (pr.getCommits() > 0) prComp.setCommits(service.getCommits(repo, pr.getNumber()));
      return taskDataHandler.createTaskData(repository, monitor, repo, prComp, comments);
    } catch (IOException e) {
      throw new CoreException(GitHub.createWrappedStatus(e));
    }
  }
Esempio n. 4
0
 public List<CommitComment> getComments(
     final IRepositoryIdProvider repository, final int pullrequestId) {
   List<CommitComment> comments = null;
   try {
     comments = service.getComments(repository, pullrequestId);
   } catch (IOException e) {
     log.error(
         "IO Exception fetching comments {}:{}",
         new Object[] {repository.generateId(), pullrequestId, e});
   }
   return comments;
 }
Esempio n. 5
0
 public PullRequest getPullRequest(
     final IRepositoryIdProvider repository, final int pullrequestId) {
   PullRequest pullrequest = null;
   try {
     pullrequest = service.getPullRequest(repository, pullrequestId);
   } catch (IOException e) {
     log.error(
         "IO Exception fetching PullRequest {}:{}",
         new Object[] {repository.generateId(), pullrequestId, e});
   }
   return pullrequest;
 }
 @Override
 public Integer doLoadInBackground() throws IOException {
   PullRequestService pullRequestService =
       (PullRequestService) Gh4Application.get().getService(Gh4Application.PULL_SERVICE);
   return pullRequestService.getPullRequests(mRepository, mState).size();
 }