Skip to content

Commit

Permalink
Fixed the getReadme() method.
Browse files Browse the repository at this point in the history
It was calling the wrong endpoint.
Fixed issue #99.
  • Loading branch information
kohsuke committed Feb 15, 2015
1 parent 18696fc commit 1dbcc4b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/kohsuke/github/GHGist.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* @see GHUser#listGists()
* @see GitHub#getGist(String)
* @see GitHub#createGist()
* @see <a href="https://developer.github.com/v3/gists/">documentation</a>
*/
public class GHGist extends GHObject {
/*package almost final*/ GHUser owner;
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -964,8 +964,12 @@ public List<GHContent> getDirectoryContent(String path, String ref) throws IOExc
return Arrays.asList(files);
}

public GHContent getReadme() throws Exception {
return getFileContent("readme");
/**
* https://developer.github.com/v3/repos/contents/#get-the-readme
*/
public GHContent getReadme() throws IOException {
Requester requester = root.retrieve();
return requester.to(getApiTailUrl("readme"), GHContent.class).wrap(this);
}

public GHContentUpdateResponse createContent(String content, String commitMessage, String path) throws IOException {
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/org/kohsuke/github/AppTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,13 @@ public void testIssueSearch() throws IOException {
}
}

@Test // issue #99
public void testReadme() throws IOException {
GHContent readme = gitHub.getRepository("github-api-test-org/test-readme").getReadme();
assertEquals(readme.getName(),"README.md");
assertEquals(readme.getContent(),"This is a markdown readme.\n");
}

private void kohsuke() {
String login = getUser().getLogin();
Assume.assumeTrue(login.equals("kohsuke") || login.equals("kohsuke2"));
Expand Down

0 comments on commit 1dbcc4b

Please sign in to comment.