Added ghRepo.getBlob(String) method

Signed-off-by: Kanstantsin Shautsou <kanstantsin.sha@gmail.com>
This commit is contained in:
Kanstantsin Shautsou
2016-12-13 04:17:27 +03:00
parent 0731f63237
commit 0780e10fa2
3 changed files with 40 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
package org.kohsuke.github;
/**
* @author Kanstantsin Shautsou
* @see <a href="https://developer.github.com/v3/git/blobs/#get-a-blob">Get a blob</a>
*/
public class GHBlob {
private String content, encoding, url, sha;
private long size;
public String getEncoding() {
return encoding;
}
public String getUrl() {
return url;
}
public String getSha() {
return sha;
}
public long getSize() {
return size;
}
public String getContent() {
return content;
}
}

View File

@@ -817,6 +817,14 @@ public class GHRepository extends GHObject {
return root.retrieve().to(url, GHTree.class).wrap(root);
}
/**
* @see <a href="https://developer.github.com/v3/git/blobs/#get-a-blob">Get a blob</a>
*/
public GHBlob getBlob(String blobSha) throws IOException {
String target = getApiTailUrl("git/blobs/" + blobSha);
return root.retrieve().to(target, GHBlob.class);
}
/**
* Gets a commit object in this repository.
*/

View File

@@ -54,14 +54,14 @@ public class GHTreeEntry {
/**
* SHA1 of this object.
* SHA1 of this blob object.
*/
public String getSha() {
return sha;
}
/**
* API URL to this Git data, such as
* API URL to this Git blob data, such as
* https://api.github.com/repos/jenkinsci
* /jenkins/git/commits/b72322675eb0114363a9a86e9ad5a170d1d07ac0
*/