Added the commit status API, first cut.

This commit is contained in:
Kohsuke Kawaguchi
2012-09-04 10:40:32 -07:00
parent 65adb2f2b4
commit 892d2acaa2
4 changed files with 125 additions and 0 deletions

View File

@@ -442,6 +442,28 @@ public class GHRepository {
};
}
public GHCommitStatus getCommitStatus(String sha1) throws IOException {
return root.retrieve(String.format("/repos/%s/%s/statuses/%s", owner.login, name, sha1), GHCommitStatus.class).wrapUp(root);
}
/**
* Creates a commit status
*
* @param targetUrl
* Optional parameter that points to the URL that has more details.
* @param description
* Optional short description.
*/
public GHCommitStatus createCommitStatus(String sha1, GHCommitState state, String targetUrl, String description) throws IOException {
return new Poster(root)
.withCredential()
.with("state",state.name().toLowerCase(Locale.ENGLISH))
.with("target_url", targetUrl)
.with("description", description)
.to(String.format("/repos/%s/%s/statuses/%s",owner.login,this.name,sha1),GHCommitStatus.class).wrapUp(root);
}
/**
*
* See https://api.github.com/hooks for possible names and their configuration scheme.