2017-03-09 197 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

謝謝,我會試試看,並讓你知道結果 –

相關問題