use of net.nemerosa.ontrack.extension.svn.db.SVNRepository in project ontrack by nemerosa.
the class SVNChangeLogServiceImpl method changeLog.
@Override
@Transactional
public SVNChangeLog changeLog(BuildDiffRequest request) {
try (Transaction ignored = transactionService.start()) {
// Gets the two builds
Build buildFrom = structureService.getBuild(request.getFrom());
Build buildTo = structureService.getBuild(request.getTo());
// Ordering of builds
if (buildFrom.id() > buildTo.id()) {
Build t = buildFrom;
buildFrom = buildTo;
buildTo = t;
}
// Gets the two branches, for each build
Branch branchFrom = buildFrom.getBranch();
Branch branchTo = buildTo.getBranch();
// Checks the branch is the same
if (branchFrom.id() != branchTo.id()) {
throw new SVNChangeLogDifferentBranchException();
}
SVNRepository svnRepository = getSVNRepository(branchFrom);
return new SVNChangeLog(UUID.randomUUID().toString(), branchFrom.getProject(), svnRepository, getSCMBuildView(svnRepository, buildFrom.getId()), getSCMBuildView(svnRepository, buildTo.getId()));
}
}
use of net.nemerosa.ontrack.extension.svn.db.SVNRepository in project ontrack by nemerosa.
the class BuildSVNInformationExtension method getInformation.
@Override
public Optional<EntityInformation> getInformation(ProjectEntity entity) {
if (entity instanceof Build) {
Build build = (Build) entity;
// Gets the branch SVN information
Property<SVNBranchConfigurationProperty> branchConfigurationProperty = propertyService.getProperty(build.getBranch(), SVNBranchConfigurationPropertyType.class);
Property<SVNProjectConfigurationProperty> projectConfigurationProperty = propertyService.getProperty(build.getBranch().getProject(), SVNProjectConfigurationPropertyType.class);
if (branchConfigurationProperty.isEmpty() || projectConfigurationProperty.isEmpty()) {
return Optional.empty();
} else {
// Loads the repository
SVNRepository repository = svnService.getRepository(projectConfigurationProperty.getValue().getConfiguration().getName());
// Gets the build history
try (Transaction ignored = transactionService.start()) {
return Optional.of(new EntityInformation(this, svnChangeLogService.getBuildSVNHistory(repository, build)));
}
}
} else {
return Optional.empty();
}
}
use of net.nemerosa.ontrack.extension.svn.db.SVNRepository in project ontrack by nemerosa.
the class AbstractTagBasedSvnRevisionLink method getRevision.
@Override
public OptionalLong getRevision(T data, Build build, SVNBranchConfigurationProperty branchConfigurationProperty) {
// Gets the tag path
Optional<String> oTagPath = getTagPath(data, build, branchConfigurationProperty);
// If present
if (oTagPath.isPresent()) {
String tagPath = oTagPath.get();
SVNRepository svnRepository = svnService.getRequiredSVNRepository(build.getBranch());
// Gets the copy event for this build
TCopyEvent lastCopyEvent = svnService.getLastCopyEvent(svnRepository.getId(), tagPath, Long.MAX_VALUE);
// Gets the revision
return lastCopyEvent != null ? OptionalLong.of(lastCopyEvent.getCopyFromRevision()) : OptionalLong.empty();
} else {
return OptionalLong.empty();
}
}
use of net.nemerosa.ontrack.extension.svn.db.SVNRepository in project ontrack by nemerosa.
the class AbstractTagBasedSvnRevisionLink method extractBuildName.
protected Optional<String> extractBuildName(T data, String path, Branch branch, SVNBranchConfigurationProperty branchConfigurationProperty) {
// Repository for the branch
SVNRepository svnRepository = svnService.getRequiredSVNRepository(branch);
// Gets the base path
Optional<String> oBasePath = svnService.getBasePath(svnRepository, branchConfigurationProperty.getCuredBranchPath());
if (!oBasePath.isPresent()) {
return Optional.empty();
}
String basePath = oBasePath.get();
// Tag base path
String tagsBasePath = basePath + "/tags/";
// Starting correctly
if (StringUtils.startsWith(path, tagsBasePath)) {
// Gets the tag part
String token = StringUtils.substringAfter(path, tagsBasePath);
// In case of /
String tagName = StringUtils.substringBefore(token, "/");
// Extracts the build name from the tag name
return getBuildName(data, tagName);
} else // Not a tag
{
return Optional.empty();
}
}
Aggregations