Skip to content
Snippets Groups Projects

Iss #118 - Add support for website_repo matching for project lookup

Merged Iss #118 - Add support for website_repo matching for project lookup
Merged Martin Lowe requested to merge malowe/main/118 into main
3 files
+ 28
3
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -12,8 +12,10 @@
@@ -12,8 +12,10 @@
package org.eclipsefoundation.git.eca.helper;
package org.eclipsefoundation.git.eca.helper;
import java.net.URI;
import java.net.URI;
 
import java.util.Arrays;
import java.util.Collections;
import java.util.Collections;
import java.util.List;
import java.util.List;
 
import java.util.Optional;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.eclipsefoundation.caching.service.CachingService;
import org.eclipsefoundation.caching.service.CachingService;
@@ -69,9 +71,20 @@ public final class ProjectHelper {
@@ -69,9 +71,20 @@ public final class ProjectHelper {
}
}
LOGGER.debug("Checking projects for repos that end with: {}", repoUrl);
LOGGER.debug("Checking projects for repos that end with: {}", repoUrl);
 
// check if the website repo matches first, returning that project if it's found
 
Optional<Project> siteProjectMatch = availableProjects
 
.stream()
 
.filter(p -> p.getWebsiteRepo().stream().anyMatch(r -> repoUrl.equals(r.getUrl())))
 
.findFirst();
 
if (siteProjectMatch.isPresent()) {
 
LOGGER
 
.trace("Found website repo match for project '{}', assuming project and returning",
 
siteProjectMatch.get().getProjectId());
 
return Arrays.asList(siteProjectMatch.get());
 
}
 
String projectNamespace = URI.create(repoUrl).getPath().substring(1).toLowerCase();
String projectNamespace = URI.create(repoUrl).getPath().substring(1).toLowerCase();
// filter the projects based on the repo URL. At least one repo in project must
// filter the projects based on the repo URL. At least one repo in project must match the repo URL to be valid
// match the repo URL to be valid
switch (provider) {
switch (provider) {
case GITLAB:
case GITLAB:
return availableProjects.stream().filter(p -> doesProjectMatchGitlabRepos(p, repoUrl, projectNamespace)).toList();
return availableProjects.stream().filter(p -> doesProjectMatchGitlabRepos(p, repoUrl, projectNamespace)).toList();
Loading