File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed
main/java/org/kohsuke/github
test/java/org/kohsuke/github Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,15 @@ GHIssue wrap(GHRepository owner) {
7979 return this ;
8080 }
8181
82+ String getRepositoryUrlPath () {
83+ String url = getUrl ().toString ();
84+ int index = url .indexOf ("/issues" );
85+ if (index == -1 ) {
86+ index = url .indexOf ("/pulls" );
87+ }
88+ return url .substring (0 , index );
89+ }
90+
8291 /**
8392 * Repository to which the issue belongs.
8493 *
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ public GHProjectColumn getColumn() throws IOException {
115115 }
116116
117117 /**
118- * Gets content.
118+ * Gets content. May be a {@link GHPullRequest} or a {@link GHIssue}.
119119 *
120120 * @return the content
121121 * @throws IOException
@@ -125,11 +125,16 @@ public GHIssue getContent() throws IOException {
125125 if (StringUtils .isEmpty (content_url ))
126126 return null ;
127127 try {
128+ GHIssue issue ;
128129 if (content_url .contains ("/pulls" )) {
129- return root ().createRequest ().withUrlPath (getContentUrl ().getPath ()).fetch (GHPullRequest .class );
130+ issue = root ().createRequest ().withUrlPath (getContentUrl ().getPath ()).fetch (GHPullRequest .class );
130131 } else {
131- return root ().createRequest ().withUrlPath (getContentUrl ().getPath ()).fetch (GHIssue .class );
132+ issue = root ().createRequest ().withUrlPath (getContentUrl ().getPath ()).fetch (GHIssue .class );
132133 }
134+ GHRepository repository =
135+ root ().createRequest ().withUrlPath (issue .getRepositoryUrlPath ()).fetch (GHRepository .class );
136+ issue .wrap (repository );
137+ return issue ;
133138 } catch (FileNotFoundException e ) {
134139 return null ;
135140 }
Original file line number Diff line number Diff line change @@ -55,6 +55,8 @@ public void testCreateCardFromIssue() throws IOException {
5555 GHIssue issue = repo .createIssue ("new-issue" ).body ("With body" ).create ();
5656 GHProjectCard card = column .createCard (issue );
5757 assertThat (card .getContentUrl (), equalTo (issue .getUrl ()));
58+ assertThat (card .getContent (), notNullValue ());
59+ assertThat (card .getContent ().getRepository (), notNullValue ());
5860 } finally {
5961 repo .delete ();
6062 }
You can’t perform that action at this time.
0 commit comments