Skip to content

Commit

Permalink
Merge pull request #161 from khoa-nd/master
Browse files Browse the repository at this point in the history
Add method to get the list of languages using in repository
  • Loading branch information
oleg-nenashev committed Mar 13, 2015
2 parents dcc3b7f + 374fdb3 commit d95c8a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,18 @@ protected void wrapUp(GHTag[] page) {
};
}

/**
* List languages for the specified repository.
* The value on the right of a language is the number of bytes of code written in that language.
* {
"C": 78769,
"Python": 7769
}
*/
public Map<String,Long> listLanguages() throws IOException {
return root.retrieve().to(getApiTailUrl("languages"), HashMap.class);
}

public String getOwnerName() {
return owner.login;
}
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/org/kohsuke/github/RepositoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,11 @@ public void listContributors() throws IOException {
private GHRepository getRepository() throws IOException {
return gitHub.getOrganization("github-api-test-org").getRepository("jenkins");
}

@Test
public void listLanguages() throws IOException {
GHRepository r = gitHub.getRepository("kohsuke/github-api");
String mainLanguage = r.getLanguage();
assertTrue(r.listLanguages().containsKey(mainLanguage));
}
}

0 comments on commit d95c8a4

Please sign in to comment.