From 6019f867c55de74632e7822fee2a26be936e5d9f Mon Sep 17 00:00:00 2001 From: Guilherme Mota Date: Tue, 19 Mar 2024 12:48:59 -0300 Subject: [PATCH 1/5] Adding support to more than 1000 repositories --- pom.xml | 6 ++-- .../GitHubSCMNavigator.java | 28 +++++++++++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 9738077a4..5d787efa0 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ - 999999-SNAPSHOT + 1781.va_153cda_09d1b_dock jenkinsci/${project.artifactId}-plugin 2.2.0 2.414.3 @@ -86,7 +86,7 @@ com.github.tomakehurst wiremock-jre8-standalone - 2.35.2 + 2.35.1 test @@ -107,7 +107,7 @@ org.awaitility awaitility - 4.2.1 + 4.2.0 test diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index 868e5311e..e32464e06 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -1019,7 +1019,7 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru String.format( "Looking up repositories for topics: '%s'", gitHubSCMNavigatorContext.getTopics()))); - repositories = searchRepositories(github, gitHubSCMNavigatorContext); + repositories = searchRepositories(github, gitHubSCMNavigatorContext, myself); } else { repositories = myself.listRepositories(100); } @@ -1114,7 +1114,7 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru String.format( "Looking up repositories for topics: '%s'", gitHubSCMNavigatorContext.getTopics()))); - repositories = searchRepositories(github, gitHubSCMNavigatorContext); + repositories = searchRepositories(github, gitHubSCMNavigatorContext, org); } else { repositories = org.listRepositories(100); } @@ -1239,13 +1239,35 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru } } - private Iterable searchRepositories(final GitHub github, final GitHubSCMNavigatorContext context) { + private Iterable searchRepositories(final GitHub github, final GitHubSCMNavigatorContext context, final GHOrganization org) { final GHRepositorySearchBuilder ghRepositorySearchBuilder = github.searchRepositories(); context.getTopics().forEach(ghRepositorySearchBuilder::topic); ghRepositorySearchBuilder.org(getRepoOwner()); if (!context.isExcludeForkedRepositories()) { ghRepositorySearchBuilder.q("fork:true"); } + + //Only the first 1000 search results are available + if (ghRepositorySearchBuilder.list().getTotalCount() > 1000) { + return org.listRepositories(100); + } + + return ghRepositorySearchBuilder.list().withPageSize(100); + } + + private Iterable searchRepositories(final GitHub github, final GitHubSCMNavigatorContext context, final GHMyself myself) { + final GHRepositorySearchBuilder ghRepositorySearchBuilder = github.searchRepositories(); + context.getTopics().forEach(ghRepositorySearchBuilder::topic); + ghRepositorySearchBuilder.org(getRepoOwner()); + if (!context.isExcludeForkedRepositories()) { + ghRepositorySearchBuilder.q("fork:true"); + } + + //Only the first 1000 search results are available + if (ghRepositorySearchBuilder.list().getTotalCount() > 1000) { + return myself.listRepositories(100); + } + return ghRepositorySearchBuilder.list().withPageSize(100); } From e46ab52362c1b503c2fc336015936dcfb831d27c Mon Sep 17 00:00:00 2001 From: Guilherme Mota Date: Tue, 19 Mar 2024 16:07:04 -0300 Subject: [PATCH 2/5] adjustment in comment --- .../plugins/github_branch_source/GitHubSCMNavigator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index e32464e06..a9f2aca4a 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -1247,7 +1247,7 @@ private Iterable searchRepositories(final GitHub github, final Git ghRepositorySearchBuilder.q("fork:true"); } - //Only the first 1000 search results are available + // Only the first 1000 search results are available if (ghRepositorySearchBuilder.list().getTotalCount() > 1000) { return org.listRepositories(100); } @@ -1263,7 +1263,7 @@ private Iterable searchRepositories(final GitHub github, final Git ghRepositorySearchBuilder.q("fork:true"); } - //Only the first 1000 search results are available + // Only the first 1000 search results are available if (ghRepositorySearchBuilder.list().getTotalCount() > 1000) { return myself.listRepositories(100); } From 642b3c31a866d4713651697eaaa6a5b05dbe11e9 Mon Sep 17 00:00:00 2001 From: Guilherme Mota Date: Tue, 19 Mar 2024 16:11:05 -0300 Subject: [PATCH 3/5] adjustment pom changelist --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 5d787efa0..2ef6296e6 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ - 1781.va_153cda_09d1b_dock + 999999-SNAPSHOT jenkinsci/${project.artifactId}-plugin 2.2.0 2.414.3 From aefef4f829302be756797c74f55affc0ba7e9bc2 Mon Sep 17 00:00:00 2001 From: Guilherme Mota Date: Tue, 19 Mar 2024 16:15:23 -0300 Subject: [PATCH 4/5] adjustment pom dependencies version --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 2ef6296e6..9738077a4 100644 --- a/pom.xml +++ b/pom.xml @@ -86,7 +86,7 @@ com.github.tomakehurst wiremock-jre8-standalone - 2.35.1 + 2.35.2 test @@ -107,7 +107,7 @@ org.awaitility awaitility - 4.2.0 + 4.2.1 test From 08373208442ddb2a00d027c8821a28a0da7d193d Mon Sep 17 00:00:00 2001 From: Guilherme Mota Date: Tue, 19 Mar 2024 16:40:02 -0300 Subject: [PATCH 5/5] spotless adjustment --- .../plugins/github_branch_source/GitHubSCMNavigator.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java index a9f2aca4a..6070a3025 100644 --- a/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java +++ b/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMNavigator.java @@ -1239,7 +1239,8 @@ public void visitSources(SCMSourceObserver observer) throws IOException, Interru } } - private Iterable searchRepositories(final GitHub github, final GitHubSCMNavigatorContext context, final GHOrganization org) { + private Iterable searchRepositories( + final GitHub github, final GitHubSCMNavigatorContext context, final GHOrganization org) { final GHRepositorySearchBuilder ghRepositorySearchBuilder = github.searchRepositories(); context.getTopics().forEach(ghRepositorySearchBuilder::topic); ghRepositorySearchBuilder.org(getRepoOwner()); @@ -1255,7 +1256,8 @@ private Iterable searchRepositories(final GitHub github, final Git return ghRepositorySearchBuilder.list().withPageSize(100); } - private Iterable searchRepositories(final GitHub github, final GitHubSCMNavigatorContext context, final GHMyself myself) { + private Iterable searchRepositories( + final GitHub github, final GitHubSCMNavigatorContext context, final GHMyself myself) { final GHRepositorySearchBuilder ghRepositorySearchBuilder = github.searchRepositories(); context.getTopics().forEach(ghRepositorySearchBuilder::topic); ghRepositorySearchBuilder.org(getRepoOwner());