added object representation for GitHub commit

This commit is contained in:
Kohsuke Kawaguchi
2012-04-24 16:11:55 -07:00
parent a8ecf0bef0
commit 53d09bb5d8
2 changed files with 216 additions and 0 deletions

View File

@@ -73,6 +73,7 @@ public class GHRepository {
private Map<Integer,GHMilestone> milestones = new HashMap<Integer, GHMilestone>();
private String master_branch;
private Map<String,GHCommit> commits = new HashMap<String, GHCommit>();
public String getDescription() {
return description;
@@ -360,6 +361,18 @@ public class GHRepository {
return root.retrieveWithAuth3(String.format("/repos/%s/%s/hooks/%d",owner.login,name,id),GHHook.class).wrap(this);
}
/**
* Gets a commit object in this repository.
*/
public GHCommit getCommit(String sha1) throws IOException {
GHCommit c = commits.get(sha1);
if (c==null) {
c = root.retrieve3(String.format("/repos/%s/%s/commits/%s",owner.login,name,sha1),GHCommit.class).wrapUp(this);
commits.put(sha1,c);
}
return c;
}
/**
*
* See https://api.github.com/hooks for possible names and their configuration scheme.