use of jetbrains.vcs.api.services.tc.PersonalSupportBatchService in project teamcity-rest by JetBrains.
the class VcsRootFinder method repositoryIdStringMatches.
static boolean repositoryIdStringMatches(@NotNull final jetbrains.buildServer.vcs.VcsRoot root, @NotNull final String repositoryIdString, final VcsManager vcsManager) {
String repositoryIdStringWithoutType;
// see also PersonalPatchUtil.mapPathEx()
final int index = repositoryIdString.indexOf(VcsMappingElement.SEPARATOR);
if (index >= 0) {
final String vcsName = repositoryIdString.substring(0, index);
if (!vcsName.equals(root.getVcsName()))
return false;
repositoryIdStringWithoutType = repositoryIdString.substring(index + VcsMappingElement.SEPARATOR.length());
} else {
// pre-TeamCity 10 compatibility
repositoryIdStringWithoutType = repositoryIdString;
}
try {
final VcsSupportCore vcsSupport = vcsManager.findVcsByName(root.getVcsName());
if (vcsSupport != null) {
final PersonalSupportBatchService personalSupportService = vcsManager.getGenericService(root.getVcsName(), PersonalSupportBatchService.class);
if (personalSupportService != null) {
// if (null != personalSupportService.mapPath(Arrays.asList(new VcsSettings(root, "")), repositoryIdStringWithoutType, true).getMappedPath())
// return true;
List<Boolean> canAffectList = personalSupportService.canAffect(Arrays.asList(new VcsSettings(root, "")), Collections.singletonList(repositoryIdStringWithoutType), true);
for (Boolean aBoolean : canAffectList) {
if (aBoolean)
return true;
}
return false;
} else {
LOG.debug("No personal support for VCS root " + LogUtil.describe(root) + " found, ignoring root in search");
}
} else {
LOG.debug("No VCS support for VCS root " + LogUtil.describe(root) + " found, ignoring root in search");
}
} catch (Exception e) {
LOG.debug("Error while retrieving mapping for VCS root " + LogUtil.describe(root) + " via mapFullPath, ignoring", e);
}
try {
Collection<VcsMappingElement> vcsMappingElements = VcsRoot.getRepositoryMappings(root, vcsManager);
for (VcsMappingElement vcsMappingElement : vcsMappingElements) {
if (vcsMappingElement.getTo().startsWith(repositoryIdString) || repositoryIdString.startsWith(vcsMappingElement.getTo())) {
// if (repositoryIdString.equals(vcsMappingElement.getTo())) {
return true;
}
}
} catch (Exception e) {
LOG.debug("Error while retrieving mapping for VCS root " + LogUtil.describe(root) + ", ignoring root in search", e);
}
return false;
}
Aggregations