public List<Issue> getIssueList() throws IOException { List<Issue> issueList = new ArrayList<Issue>(); IssueService service = new IssueService(client); Map<String, String> issueFilter = new HashMap<String, String>(); if (includeOpenIssues) { // Adding open issues for (org.eclipse.egit.github.core.Issue issue : service.getIssues(githubOwner, githubRepo, issueFilter)) { if (!onlyMilestoneIssues || issue.getMilestone() != null) { issueList.add(createIssue(issue)); } } } // Adding closed issues issueFilter.put("state", "closed"); for (org.eclipse.egit.github.core.Issue issue : service.getIssues(githubOwner, githubRepo, issueFilter)) { if (!onlyMilestoneIssues || issue.getMilestone() != null) { issueList.add(createIssue(issue)); } } return issueList; }
@Override public void doLoadInBackground(HashMap<Integer, Object> result) throws IOException { Gh4Application app = (Gh4Application) getContext().getApplicationContext(); GitHubClient client = new DefaultClient(); client.setOAuth2Token(app.getAuthToken()); IssueService issueService = new IssueService(client); result.put(LoaderResult.DATA, issueService.getComments(mRepoOwner, mRepoName, mIssueNumber)); }
@RequestMapping("/output") public String func(HttpServletRequest req, HttpServletResponse resp) throws Exception { String outputURL = "first"; try { String path = req.getParameter("path"); // System.out.println(path); String arr[] = path.split("/"); String repoName = arr[arr.length - 1]; String user = arr[arr.length - 2]; // System.out.println(user+" - " +path); Set<Issue> lessSeven = new LinkedHashSet<Issue>(); Set<Issue> between24and7 = new LinkedHashSet<Issue>(); Set<Issue> greaterSeven = new LinkedHashSet<Issue>(); Date yesterday = new Date(System.currentTimeMillis() - (24 * 60 * 60 * 1000)); // String yesterdayDate=sdf.format(yesterday); Date DaysAgo7Date = new Date(System.currentTimeMillis() - 7 * 24 * 60 * 60 * 1000); // String DaysAgo7=sdf.format(DaysAgo7Date); GitHubClient git = new GitHubClient(); // git.setOAuth2Token("39de076299133c5c995ee00b1573f9826887e5bd"); git.setCredentials("TheMask", "sugandh4"); RepositoryService repoService = new RepositoryService(git); IssueService issueService = new IssueService(git); Repository repo = null; repo = repoService.getRepository(user, repoName); System.out.println(repo.getName()); System.out.println(repo.getOpenIssues()); Map<String, String> paramIssue = new HashMap<String, String>(); paramIssue.put("state", "open"); // paramIssue.put("sort", "created"); List<Issue> issueList = issueService.getIssues(repo, paramIssue); for (Issue issue : issueList) { // System.out.println(issue.getCreatedAt()); if (issue.getCreatedAt().after(yesterday)) lessSeven.add(issue); else if ((issue.getCreatedAt().before(yesterday)) && (issue.getCreatedAt().after(DaysAgo7Date))) between24and7.add(issue); else greaterSeven.add(issue); } HttpSession session = req.getSession(); session.setAttribute("firstList", lessSeven); session.setAttribute("secondList", between24and7); session.setAttribute("thirdList", greaterSeven); } catch (Exception e) { System.out.println(e.getMessage()); outputURL = "error"; } System.out.println(outputURL); return outputURL; }
@Bean public IssueService issueService() { IssueService issueService = new IssueService(); issueService .getClient() .setCredentials( env.getRequiredProperty(USUARIO_GIT), env.getRequiredProperty(PASSWORD_GIT)); issueService.getClient().setOAuth2Token(TOKEN_GIT); return issueService; }
@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; }
@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)); } }
@Override public Issue run(Account account) throws Exception { return store.addIssue(service.createIssue(repository, issue)); }