函数searchissue()from egit不会返回GitHub存储库中的所有问题 [英] Function searchissue() from egit don't return all issues in a GitHub repository
问题描述
我试图从GitHub中的存储库中找到问题,但是当我使用IssueService类中的searchissues()函数时,它只返回10个问题。我搜索的存储库有超过40个注册的问题。
I am trying to find issues from a repository in the GitHub, but when I use the searchissues() function from the IssueService class, that only returns 10 issues. The repository that i am search has more then 40 issues registred.
如何返回在我的存储库中注册的所有问题?
How can i return all de issues registred in my repository?
public static void main(String[] args) throws IOException {
GitHubClient client = new GitHubClient();
client.setCredentials("xxxxxx", "xxxxx");
int openIssue = 0;
int closedIssue = 0;
RepositoryService repositoryService = new RepositoryService(client);
IRepositoryIdProvider repoId = new repositoryId("purifycss","purifycss");
IssueService issueService = new IssueService(client);
for(SearchIssue search : issueService.searchIssues(repoId, "all", " ")){
System.out.println(search.getTitle() + " " + search.getState() + " " + search.getNumber());
if(search.getState().equalsIgnoreCase("open"))
openIssue++;
if(search.getState().equalsIgnoreCase("closed"))
closedIssue++;
}
System.out.println(openIssue + " " + closedIssue);
}
推荐答案
与 GitHub API分页相关。
查看测试 org.eclipse.egit.github.core.tests / src / org / eclipse / egit / github / core / tests / live / IssueTest.java
#L138-L156 :它显示了如何遍历结果的页面,而不是结果直接(默认限制)
$ b
Check out the test org.eclipse.egit.github.core.tests/src/org/eclipse/egit/github/core/tests/live/IssueTest.java
#L138-L156: it shows how to iterate over pages of results, instead of the results directly (limited by default)
IssueService service = new IssueService(client);
Map<String, String> params = new HashMap<String, String>();
params.put(IssueService.FILTER_STATE, IssueService.STATE_CLOSED);
PageIterator<Issue> iterator = service.pageIssues("schacon", "showoff",
params, 1);
assertNotNull(iterator);
assertTrue(iterator.hasNext());
Collection<Issue> page = iterator.next();
int pages = iterator.getLastPage();
这篇关于函数searchissue()from egit不会返回GitHub存储库中的所有问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!