Skip to content

Commit 1827735

Browse files
committed
Generalize retrieval of source RPM from the Testing Farm URL
1 parent 68e8e93 commit 1827735

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

  • src/main/java/org/fedoraproject/javapackages/validator

src/main/java/org/fedoraproject/javapackages/validator/MainTmt.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ public class MainTmt extends Main {
4040
private Optional<URI> TESTING_FARM_GIT_URL = Optional.empty();
4141
private Map<String, List<LogEntry>> additionalLogs = new TreeMap<>();
4242

43-
private static final Pattern URL_PACKAGE_NAME_PATTERN = Pattern.compile(".*/rpms/(.*)");
44-
4543
private static String getenv(String key) {
4644
var result = System.getenv(key);
4745
if (result == null) {
@@ -225,15 +223,27 @@ protected Map<String, Validator> select(Map<String, Validator> validators) throw
225223
@Override
226224
protected Iterable<RpmPackage> findRpms() throws Exception {
227225
logger.debug("TESTING_FARM_GIT_URL: {0}", Decorated.plain(TESTING_FARM_GIT_URL.map(String::valueOf).orElse("")));
226+
var packageName = TESTING_FARM_GIT_URL.map(uri -> {
227+
var uriPath = uri.getPath();
228+
var begin = uriPath.lastIndexOf('/');
229+
if (begin == -1) {
230+
begin = 0;
231+
}
232+
var end = uriPath.length();
233+
if (uriPath.endsWith(".git")) {
234+
end -= 4;
235+
}
236+
return uriPath.substring(begin, end);
237+
});
238+
packageName.ifPresent(name -> {
239+
logger.debug("Tested source package: {0}", Decorated.plain(name));
240+
});
228241
var rpms = new ArrayList<RpmPackage>();
229242
var it = ArgFileIterator.create(parameters.argPaths);
230243
while (it.hasNext()) {
231244
var rpm = it.next();
232-
if (TESTING_FARM_GIT_URL.isPresent()) {
233-
var matcher = URL_PACKAGE_NAME_PATTERN.matcher(TESTING_FARM_GIT_URL.get().getPath());
234-
if (matcher.matches() && !matcher.group(1).equals(rpm.getInfo().getSourceName())) {
235-
continue;
236-
}
245+
if (packageName.isPresent() && packageName.get().equals(rpm.getInfo().getSourceName())) {
246+
continue;
237247
}
238248
rpms.add(rpm);
239249
}

0 commit comments

Comments
 (0)