From 0780e10fa2eac368c5adf4f824c6bbdb3030c31d Mon Sep 17 00:00:00 2001 From: Kanstantsin Shautsou Date: Tue, 13 Dec 2016 04:17:27 +0300 Subject: [PATCH] Added ghRepo.getBlob(String) method Signed-off-by: Kanstantsin Shautsou --- src/main/java/org/kohsuke/github/GHBlob.java | 30 +++++++++++++++++++ .../java/org/kohsuke/github/GHRepository.java | 8 +++++ .../java/org/kohsuke/github/GHTreeEntry.java | 4 +-- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/main/java/org/kohsuke/github/GHBlob.java diff --git a/src/main/java/org/kohsuke/github/GHBlob.java b/src/main/java/org/kohsuke/github/GHBlob.java new file mode 100644 index 0000000000..f795da00d4 --- /dev/null +++ b/src/main/java/org/kohsuke/github/GHBlob.java @@ -0,0 +1,30 @@ +package org.kohsuke.github; + +/** + * @author Kanstantsin Shautsou + * @see Get a blob + */ +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; + } +} diff --git a/src/main/java/org/kohsuke/github/GHRepository.java b/src/main/java/org/kohsuke/github/GHRepository.java index f34ea85004..88346ea4cd 100644 --- a/src/main/java/org/kohsuke/github/GHRepository.java +++ b/src/main/java/org/kohsuke/github/GHRepository.java @@ -817,6 +817,14 @@ public GHTree getTreeRecursive(String sha, int recursive) throws IOException { return root.retrieve().to(url, GHTree.class).wrap(root); } + /** + * @see Get a blob + */ + 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. */ diff --git a/src/main/java/org/kohsuke/github/GHTreeEntry.java b/src/main/java/org/kohsuke/github/GHTreeEntry.java index e3d831c073..8359c40cda 100644 --- a/src/main/java/org/kohsuke/github/GHTreeEntry.java +++ b/src/main/java/org/kohsuke/github/GHTreeEntry.java @@ -54,14 +54,14 @@ public String getType() { /** - * 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 */