@@ -55,10 +55,16 @@ public GHRepositorySearchBuilder forks(String v) {
5555 /**
5656 * Searching in forks
5757 *
58- * By default, forks are not shown in search results. Forks are only indexed for code search when they have more
59- * stars than the parent repository. You will not be able to search the code in a fork that has less stars than its
60- * parent. To show forks with more stars than the parent repository in code search results, add
61- * Fork.ALL_INCLUDING_FORKS or Fork.FORKS_ONLY.
58+ * The default search mode is {@link Fork#PARENT_ONLY}. In that mode, forks are not included in search results.
59+ *
60+ * <p>
61+ * Passing {@link Fork#PARENT_AND_FORKS} or {@link Fork#FORKS_ONLY} will show results from forks, but only if they
62+ * have more stars than the parent repository.
63+ *
64+ * <p>
65+ * IMPORTANT: Regardless of this setting, no search results will ever be returned for forks with equal or fewer
66+ * stars than the parent repository. Forks with less stars than the parent repository are not included in the index
67+ * for code searching.
6268 *
6369 * @param fork
6470 * search mode for forks
@@ -71,7 +77,7 @@ public GHRepositorySearchBuilder forks(String v) {
7177 *
7278 */
7379 public GHRepositorySearchBuilder fork (Fork fork ) {
74- if (fork == Fork .DEFAULT ) {
80+ if (Fork .PARENT_ONLY . equals ( fork ) ) {
7581 this .terms .removeIf (term -> term .contains ("fork:" ));
7682 return this ;
7783 }
@@ -82,21 +88,21 @@ public GHRepositorySearchBuilder fork(Fork fork) {
8288 /**
8389 * Search by repository visibility
8490 *
85- * If visibility param value equals to GHRepository.Visibility.UNKNOWN, this search criteria will be ignored.
86- *
8791 * @param visibility
8892 * repository visibility
8993 *
9094 * @return the gh repository search builder
91- *
95+ * @throws GHException
96+ * if {@link GHRepository.Visibility#UNKNOWN} is passed. UNKNOWN is a placeholder for unexpected values
97+ * encountered when reading data.
9298 * @see <a href=
9399 * "https://docs.github.com/en/github/searching-for-information-on-github/searching-on-github/searching-for-repositories#search-by-repository-visibility">Search
94100 * by repository visibility</a>
95- *
96101 */
97102 public GHRepositorySearchBuilder visibility (GHRepository .Visibility visibility ) {
98103 if (visibility == GHRepository .Visibility .UNKNOWN ) {
99- return this ;
104+ throw new GHException (
105+ "UNKNOWN is a placeholder for unexpected values encountered when reading data. It cannot be passed as a search parameter." );
100106 }
101107
102108 return q ("is:" + visibility );
@@ -211,15 +217,30 @@ public enum Sort {
211217 }
212218
213219 /**
214- * The enum Fork.
215- *
216- * By default, forks are not shown in search results. Forks are only indexed for code search when they have more
217- * stars than the parent repository. You will not be able to search the code in a fork that has less stars than its
218- * parent. To show forks with more stars than the parent repository in code search results, add
219- * Fork.ALL_INCLUDING_FORKS or Fork.FORKS_ONLY.
220+ * The enum for Fork search mode
220221 */
221222 public enum Fork {
222- ALL_INCLUDING_FORKS ("true" ), FORKS_ONLY ("only" ), DEFAULT ("ignore" );
223+
224+ /**
225+ * Search in the parent repository and in forks with more stars than the parent repository.
226+ *
227+ * Forks with the same or fewer stars than the parent repository are still ignored.
228+ */
229+ PARENT_AND_FORKS ("true" ),
230+
231+ /**
232+ * Search only in forks with more stars than the parent repository.
233+ *
234+ * The parent repository is ignored. If no forks have more stars than the parent, no results will be returned.
235+ */
236+ FORKS_ONLY ("only" ),
237+
238+ /**
239+ * (Default) Search only the parent repository.
240+ *
241+ * Forks are ignored.
242+ */
243+ PARENT_ONLY ("" );
223244
224245 private String filterMode ;
225246 Fork (String mode ) {
0 commit comments