Skip to content

Commit 0780e10

Browse files
committed
Added ghRepo.getBlob(String) method
Signed-off-by: Kanstantsin Shautsou <kanstantsin.sha@gmail.com>
1 parent 0731f63 commit 0780e10

3 files changed

Lines changed: 40 additions & 2 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.kohsuke.github;
2+
3+
/**
4+
* @author Kanstantsin Shautsou
5+
* @see <a href="https://developer.github.com/v3/git/blobs/#get-a-blob">Get a blob</a>
6+
*/
7+
public class GHBlob {
8+
private String content, encoding, url, sha;
9+
private long size;
10+
11+
public String getEncoding() {
12+
return encoding;
13+
}
14+
15+
public String getUrl() {
16+
return url;
17+
}
18+
19+
public String getSha() {
20+
return sha;
21+
}
22+
23+
public long getSize() {
24+
return size;
25+
}
26+
27+
public String getContent() {
28+
return content;
29+
}
30+
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,14 @@ public GHTree getTreeRecursive(String sha, int recursive) throws IOException {
817817
return root.retrieve().to(url, GHTree.class).wrap(root);
818818
}
819819

820+
/**
821+
* @see <a href="https://developer.github.com/v3/git/blobs/#get-a-blob">Get a blob</a>
822+
*/
823+
public GHBlob getBlob(String blobSha) throws IOException {
824+
String target = getApiTailUrl("git/blobs/" + blobSha);
825+
return root.retrieve().to(target, GHBlob.class);
826+
}
827+
820828
/**
821829
* Gets a commit object in this repository.
822830
*/

src/main/java/org/kohsuke/github/GHTreeEntry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ public String getType() {
5454

5555

5656
/**
57-
* SHA1 of this object.
57+
* SHA1 of this blob object.
5858
*/
5959
public String getSha() {
6060
return sha;
6161
}
6262

6363
/**
64-
* API URL to this Git data, such as
64+
* API URL to this Git blob data, such as
6565
* https://api.github.com/repos/jenkinsci
6666
* /jenkins/git/commits/b72322675eb0114363a9a86e9ad5a170d1d07ac0
6767
*/

0 commit comments

Comments
 (0)