diff --git a/src/main/java/org/kohsuke/github/GHIssue.java b/src/main/java/org/kohsuke/github/GHIssue.java index 2f9686ae22..aec17cc4f0 100644 --- a/src/main/java/org/kohsuke/github/GHIssue.java +++ b/src/main/java/org/kohsuke/github/GHIssue.java @@ -149,6 +149,9 @@ protected static List getLogins(Collection users) { /** The number. */ protected int number; + /** The GitHub App that opened the issue on behalf of a user. */ + protected GHApp performedViaGithubApp; + /** The pull request. */ protected GHIssue.PullRequest pullRequest; @@ -463,6 +466,16 @@ public int getNumber() { return number; } + /** + * Gets the GitHub App that opened this issue on behalf of a user. + * + * @return the GitHub App, or null if the issue was not opened through one + */ + @SuppressFBWarnings(value = { "EI_EXPOSE_REP" }, justification = "Expected behavior") + public GHApp getPerformedViaGithubApp() { + return performedViaGithubApp; + } + /** * Returns non-null if this issue is a shadow of a pull request. * diff --git a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java index 8d8b5af056..f6f63ebd82 100644 --- a/src/test/java/org/kohsuke/github/GHEventPayloadTest.java +++ b/src/test/java/org/kohsuke/github/GHEventPayloadTest.java @@ -717,6 +717,7 @@ public void issues() throws Exception { assertThat(event.getIssue().getState(), is(GHIssueState.OPEN)); assertThat(event.getIssue().getLabels().size(), is(1)); assertThat(event.getIssue().getLabels().iterator().next().getName(), is("bug")); + assertThat(event.getIssue().getPerformedViaGithubApp().getSlug(), is("octoapp")); assertThat(event.getRepository().getName(), is("public-repo")); assertThat(event.getRepository().getOwner().getLogin(), is("baxterthehacker")); assertThat(event.getSender().getLogin(), is("baxterthehacker")); diff --git a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/issues.json b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/issues.json index f047761811..2b94ec552e 100644 --- a/src/test/resources/org/kohsuke/github/GHEventPayloadTest/issues.json +++ b/src/test/resources/org/kohsuke/github/GHEventPayloadTest/issues.json @@ -45,6 +45,11 @@ "created_at": "2015-05-05T23:40:28Z", "updated_at": "2015-05-05T23:40:28Z", "closed_at": null, + "performed_via_github_app": { + "id": 1, + "slug": "octoapp", + "name": "Octocat App" + }, "body": "It looks like you accidently spelled 'commit' with two 't's." }, "repository": {