Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 811b96b

Browse filesBrowse files
Implement the ability to retrieve content from a particular ref.
1 parent f320785 commit 811b96b
Copy full SHA for 811b96b

File tree

Expand file treeCollapse file tree

1 file changed

+22
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+22
-2
lines changed

‎src/main/java/org/kohsuke/github/GHRepository.java

Copy file name to clipboardExpand all lines: src/main/java/org/kohsuke/github/GHRepository.java
+22-2Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,11 +736,31 @@ public GHMilestone getMilestone(int number) throws IOException {
736736
}
737737

738738
public GHContent getFileContent(String path) throws IOException {
739-
return root.retrieve().to(String.format("/repos/%s/%s/contents/%s", owner.login, name, path), GHContent.class).wrap(this);
739+
return getFileContent(path, null);
740+
}
741+
742+
public GHContent getFileContent(String path, String ref) throws IOException {
743+
Requester requester = root.retrieve();
744+
String target = String.format("/repos/%s/%s/contents/%s", owner.login, name, path);
745+
746+
if (ref != null)
747+
target = target + "?ref=" + ref;
748+
749+
return requester.to(target, GHContent.class).wrap(this);
740750
}
741751

742752
public List<GHContent> getDirectoryContent(String path) throws IOException {
743-
GHContent[] files = root.retrieve().to(String.format("/repos/%s/%s/contents/%s", owner.login, name, path), GHContent[].class);
753+
return getDirectoryContent(path, null);
754+
}
755+
756+
public List<GHContent> getDirectoryContent(String path, String ref) throws IOException {
757+
Requester requester = root.retrieve();
758+
String target = String.format("/repos/%s/%s/contents/%s", owner.login, name, path);
759+
760+
if (ref != null)
761+
target = target + "?ref=" + ref;
762+
763+
GHContent[] files = requester.to(target, GHContent[].class);
744764

745765
GHContent.wrap(files, this);
746766

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.