Skip to content

Commit

Permalink
Added ghRepo.getBlob(String) method
Browse files Browse the repository at this point in the history
Signed-off-by: Kanstantsin Shautsou <[email protected]>
  • Loading branch information
KostyaSha committed Dec 13, 2016
1 parent 0731f63 commit 096c78a
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
35 changes: 35 additions & 0 deletions src/main/java/org/kohsuke/github/GHBlob.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package org.kohsuke.github;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.codec.DecoderException;

import static org.apache.commons.codec.binary.Base64.decodeBase64;

/**
* @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;
}
}
8 changes: 8 additions & 0 deletions src/main/java/org/kohsuke/github/GHRepository.java
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,14 @@ public GHTree getTreeRecursive(String sha, int recursive) throws IOException {
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.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/kohsuke/github/GHTreeEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down

0 comments on commit 096c78a

Please sign in to comment.