diff options
author | Pierre <pierre.guillot@sonarsource.com> | 2021-07-01 17:24:17 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-07-02 20:03:12 +0000 |
commit | 96a4d055bf47973e6c4ed4373769d647fde8e0fd (patch) | |
tree | 85b81b550898617df980f9da178d5b45de9cdcd1 /server/sonar-alm-client | |
parent | c82cfcc86efa93863de8229a0d6b836ad16275b6 (diff) | |
download | sonarqube-96a4d055bf47973e6c4ed4373769d647fde8e0fd.tar.gz sonarqube-96a4d055bf47973e6c4ed4373769d647fde8e0fd.zip |
SONAR-14463 include forked repo in GH repo search
Diffstat (limited to 'server/sonar-alm-client')
2 files changed, 5 insertions, 5 deletions
diff --git a/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubApplicationClientImpl.java b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubApplicationClientImpl.java index ddb72bd65f1..118723447cd 100644 --- a/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubApplicationClientImpl.java +++ b/server/sonar-alm-client/src/main/java/org/sonar/alm/client/github/GithubApplicationClientImpl.java @@ -167,7 +167,7 @@ public class GithubApplicationClientImpl implements GithubApplicationClient { @Override public Repositories listRepositories(String appUrl, AccessToken accessToken, String organization, @Nullable String query, int page, int pageSize) { checkPageArgs(page, pageSize); - String searchQuery = "org:" + organization; + String searchQuery = "fork:true+org:" + organization; if (query != null) { searchQuery = query.replace(" ", "+") + "+" + searchQuery; } diff --git a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationClientImplTest.java b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationClientImplTest.java index f98a7ce8620..3b823daab6a 100644 --- a/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationClientImplTest.java +++ b/server/sonar-alm-client/src/test/java/org/sonar/alm/client/github/GithubApplicationClientImplTest.java @@ -404,7 +404,7 @@ public class GithubApplicationClientImplTest { assertThatThrownBy(() -> underTest.listRepositories(appUrl, accessToken, "test", null, 1, 100)) .isInstanceOf(IllegalStateException.class) - .hasMessage("Failed to list all repositories of 'test' accessible by user access token on 'https://github.sonarsource.com' using query 'org:test'"); + .hasMessage("Failed to list all repositories of 'test' accessible by user access token on 'https://github.sonarsource.com' using query 'fork:true+org:test'"); } @Test @@ -434,7 +434,7 @@ public class GithubApplicationClientImplTest { + " \"total_count\": 0\n" + "}"; - when(httpClient.get(appUrl, accessToken, String.format("/search/repositories?q=%s&page=%s&per_page=%s", "org:github", 1, 100))) + when(httpClient.get(appUrl, accessToken, String.format("/search/repositories?q=%s&page=%s&per_page=%s", "fork:true+org:github", 1, 100))) .thenReturn(new OkGetResponse(responseJson)); GithubApplicationClient.Repositories repositories = underTest.listRepositories(appUrl, accessToken, "github", null, 1, 100); @@ -522,7 +522,7 @@ public class GithubApplicationClientImplTest { + " ]\n" + "}"; - when(httpClient.get(appUrl, accessToken, String.format("/search/repositories?q=%s&page=%s&per_page=%s", "org:github", 1, 100))) + when(httpClient.get(appUrl, accessToken, String.format("/search/repositories?q=%s&page=%s&per_page=%s", "fork:true+org:github", 1, 100))) .thenReturn(new OkGetResponse(responseJson)); GithubApplicationClient.Repositories repositories = underTest.listRepositories(appUrl, accessToken, "github", null, 1, 100); @@ -577,7 +577,7 @@ public class GithubApplicationClientImplTest { + " ]\n" + "}"; - when(httpClient.get(appUrl, accessToken, String.format("/search/repositories?q=%s&page=%s&per_page=%s", "world+org:github", 1, 100))) + when(httpClient.get(appUrl, accessToken, String.format("/search/repositories?q=%s&page=%s&per_page=%s", "world+fork:true+org:github", 1, 100))) .thenReturn(new GithubApplicationHttpClient.GetResponse() { @Override public Optional<String> getNextEndPoint() { |