Skip to content

Commit e0dbcca

Browse files
committed
Add authorAssociation field and getter to GHIssue
Deserialize the `author_association` field from the GitHub REST API on issues and pull requests. Uses the same String-field + EnumUtils pattern as GHIssueComment for forward-compatible enum parsing.
1 parent 3622553 commit e0dbcca

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

src/main/java/org/kohsuke/github/GHIssue.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ protected static List<String> getLogins(Collection<GHUser> users) {
121121
/** The assignees. */
122122
protected GHUser[] assignees;
123123

124+
/** The author's association with the repository. */
125+
protected String authorAssociation;
126+
124127
/** The body. */
125128
@SkipFromToString
126129
protected String body;
@@ -349,6 +352,17 @@ public List<GHUser> getAssignees() {
349352
return Collections.unmodifiableList(Arrays.asList(assignees));
350353
}
351354

355+
/**
356+
* Gets the author's association with the repository.
357+
*
358+
* @return the author association
359+
*/
360+
public GHCommentAuthorAssociation getAuthorAssociation() {
361+
return EnumUtils.getEnumOrDefault(GHCommentAuthorAssociation.class,
362+
authorAssociation,
363+
GHCommentAuthorAssociation.UNKNOWN);
364+
}
365+
352366
/**
353367
* The description of this pull request.
354368
*

src/test/java/org/kohsuke/github/GHIssueTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public void createIssue() throws Exception {
169169
GHRepository repo = getRepository();
170170
GHIssue issue = repo.createIssue(name).body("## test").create();
171171
assertThat(issue.getTitle(), equalTo(name));
172+
assertThat(issue.getAuthorAssociation(), equalTo(GHCommentAuthorAssociation.NONE));
172173
}
173174

174175
/**

0 commit comments

Comments
 (0)