2017-03-09 43 views
0

可以通过提供其提交哈希来找到此处的github REST api V3here如何从org.kohsuke.github java api获得相同的发现在这link?我写了以下程序,但不知道如何继续获取我需要的代码。请帮帮我。在此先感谢如何使用org.kohsuke.github库来获取有关给定提交的详细信息

public void apiCallerFromGithubLibrary() { 

     try { 
      GitHub gitHub = GitHub.connectUsingPassword("username", "password"); 
      System.out.println(gitHub.isCredentialValid()); 

      //search content 
      GHContentSearchBuilder ghContentSearchBuilder = gitHub.searchContent(); 
      ghContentSearchBuilder.q("hash%3A380b33f74893e15c8db8b86b6b53682a64928695"); 



     } catch (IOException e) { 
      e.printStackTrace(); 
     } 


    } 

回答

0

Github docs,对于搜索查询的语法使用:不是%,所以像:

searchBuilder.q("hash:124a9a0ee1d8f1e15e833aff432fbb3b5"); 

除此之外,它看起来像你是在路上。

the Unit Tests for the library you are using中有一些搜索工作的例子。

我想你想要做的事,如:

PagedSearchIterable<GHContent> iterableContent = 
    gitHub.searchContent() 
     .q("hash:124a9a0ee1d8f1e15e833aff432fbb3b5") 
     .list(); 

// Iterate over content 
GHContent content = iterableContent.iterator().next(); // etc.. 

GHContentSearchBuilder您使用直接实际上是在调用友好searchContent()方法返回,在GitHub类的顶层API类型。

请注意,我以前从未使用过这个库,所以可能会有一些空白来填充。但希望这会让您开始。

+0

谢谢,我会试试看,并让你知道结果 –

相关问题