File tree Expand file tree Collapse file tree
main/java/org/kohsuke/github
test/java/org/kohsuke/github Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package org .kohsuke .github ;
22
3+ import java .io .IOException ;
34import java .util .Locale ;
45
6+ import org .apache .commons .lang .StringUtils ;
7+
58/**
69 * Search commits.
710 *
@@ -104,9 +107,29 @@ private static class CommitSearchResult extends SearchResult<GHCommit> {
104107
105108 @ Override
106109 /*package*/ GHCommit [] getItems (GitHub root ) {
110+ for (GHCommit commit : items ) {
111+ String repoName = getRepoName (commit .url );
112+ try {
113+ GHRepository repo = root .getRepository (repoName );
114+ commit .wrapUp (repo );
115+ } catch (IOException ioe ) {}
116+ }
107117 return items ;
108118 }
109119 }
120+
121+ /**
122+ * @param commitUrl a commit URL
123+ * @return the repo name ("username/reponame")
124+ */
125+ private static String getRepoName (String commitUrl ) {
126+ if (StringUtils .isBlank (commitUrl )) {
127+ return null ;
128+ }
129+ int indexOfUsername = (GitHub .GITHUB_URL + "/repos/" ).length ();
130+ String [] tokens = commitUrl .substring (indexOfUsername ).split ("/" , 3 );
131+ return tokens [0 ] + '/' + tokens [1 ];
132+ }
110133
111134 @ Override
112135 protected String getApiUrl () {
Original file line number Diff line number Diff line change @@ -689,6 +689,9 @@ public void testMemberPagenation() throws IOException {
689689 public void testCommitSearch () throws IOException {
690690 PagedSearchIterable <GHCommit > r = gitHub .searchCommits ().author ("kohsuke" ).list ();
691691 assertTrue (r .getTotalCount () > 0 );
692+
693+ GHCommit firstCommit = r .iterator ().next ();
694+ assertTrue (firstCommit .getFiles ().size () > 0 );
692695 }
693696
694697 @ Test
You can’t perform that action at this time.
0 commit comments