Skip to content

Commit

Permalink
Merge pull request #177 from infm/feat/notif
Browse files Browse the repository at this point in the history
Added getters for the objects notifications refer to
  • Loading branch information
kohsuke committed Apr 13, 2015
2 parents 3fb8e5f + b058c39 commit f482f77
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/org/kohsuke/github/GHThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ public String getType() {
return subject.type;
}

public GHIssue getBoundIssue() throws IOException {
if (!"Issue".equals(subject.type))
throw new IllegalStateException("Notification doesn't point to Issue");
return repository.getIssue(
Integer.parseInt(subject.url.substring(subject.url.lastIndexOf('/') + 1)));
}

public GHPullRequest getBoundPullRequest() throws IOException {
if (!"PullRequest".equals(subject.type))
throw new IllegalStateException("Notification doesn't point to PullRequest");
return repository.getPullRequest(
Integer.parseInt(subject.url.substring(subject.url.lastIndexOf('/') + 1)));
}

public GHCommit getBoundCommit() throws IOException {
if (!"Commit".equals(subject.type))
throw new IllegalStateException("Notification doesn't point to Commit");
return repository.getCommit(subject.url.substring(subject.url.lastIndexOf('/') + 1));
}

/*package*/ GHThread wrap(GitHub root) {
this.root = root;
if (this.repository!=null)
Expand Down

0 comments on commit f482f77

Please sign in to comment.