Skip to content

Commit 859c50c

Browse files
authored
Merge pull request #326 from avimanyum/reset_exclude_list
Resetting the list of orgs to include or exclude in the search for each image
2 parents 51c97da + 9ea7bc8 commit 859c50c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtil.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,11 @@ protected Optional<List<PagedSearchIterable<GHContent>>> getSearchResultsExcludi
177177
Optional<List<PagedSearchIterable<GHContent>>> contentsForOrgWithMaximumHits;
178178
contentsForOrgWithMaximumHits = findFilesWithImage(image, orgsToInclude, gitApiSearchLimit);
179179

180-
orgsToExclude.put(orgWithMaximumHits, false);
181-
log.info("Running search by excluding the orgs {}.", orgsToExclude.keySet().toString());
180+
final Map<String, Boolean> orgsToExcludeFromSearch = new HashMap<>(orgsToExclude);
181+
orgsToExcludeFromSearch.put(orgWithMaximumHits, false);
182+
log.info("Running search by excluding the orgs {}.", orgsToExcludeFromSearch.keySet());
182183
Optional<List<PagedSearchIterable<GHContent>>> contentsExcludingOrgWithMaximumHits;
183-
contentsExcludingOrgWithMaximumHits = findFilesWithImage(image, orgsToExclude, gitApiSearchLimit);
184+
contentsExcludingOrgWithMaximumHits = findFilesWithImage(image, orgsToExcludeFromSearch, gitApiSearchLimit);
184185
if (contentsForOrgWithMaximumHits.isPresent()) {
185186
allContentsWithImage.addAll(contentsForOrgWithMaximumHits.get());
186187
}

dockerfile-image-update/src/test/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtilTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,8 @@ public void getSearchResultsExcludingOrgWithMostHits() throws Exception {
330330
Map<String, Boolean> orgsToIncludeOrExclude = new HashMap<>();
331331

332332
assertEquals((dockerfileGitHubUtil.getSearchResultsExcludingOrgWithMostHits("image", contentsWithImage, orgsToIncludeOrExclude, 1000)).get().size(), 2);
333+
//This check ensures that the parameter passed to the method is not modified. Instead, the method creates a local copy of the map and modifies that.
334+
assertEquals(orgsToIncludeOrExclude.size(), 0);
333335
}
334336

335337
@Test

0 commit comments

Comments
 (0)