diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index 8570a09bb1..1c62c6c4d5 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -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 listLanguages() throws IOException { + return root.retrieve().to(getApiTailUrl("languages"), HashMap.class); + } + public String getOwnerName() { return owner.login; } diff --git a/src/test/java/org/kohsuke/github/RepositoryTest.java b/src/test/java/org/kohsuke/github/RepositoryTest.java index 6862ace7be..61cdc09dca 100644 --- a/src/test/java/org/kohsuke/github/RepositoryTest.java +++ b/src/test/java/org/kohsuke/github/RepositoryTest.java @@ -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)); + } }