Search in sources :

Example 6 with SVNRepository

use of net.nemerosa.ontrack.extension.svn.db.SVNRepository in project ontrack by nemerosa.

the class SVNHealthIndicator method getHealth.

@Override
protected Health getHealth(SVNConfiguration config) {
    // Just gets the latest revision
    SVNRepository repository = svnService.getRepository(config.getName());
    try (Transaction ignored = transactionService.start()) {
        SVNURL url = SVNUtils.toURL(repository.getConfiguration().getUrl());
        Health.Builder builder = Health.unknown();
        try {
            long repositoryRevision = svnClient.getRepositoryRevision(repository, url);
            return builder.up().withDetail("revision", repositoryRevision).build();
        } catch (Exception ex) {
            return builder.down(ex).build();
        }
    }
}
Also used : Transaction(net.nemerosa.ontrack.tx.Transaction) Health(org.springframework.boot.actuate.health.Health) SVNURL(org.tmatesoft.svn.core.SVNURL) SVNRepository(net.nemerosa.ontrack.extension.svn.db.SVNRepository)

Example 7 with SVNRepository

use of net.nemerosa.ontrack.extension.svn.db.SVNRepository in project ontrack by nemerosa.

the class SVNChangeLogTest method branch_low.

@Test
public void branch_low() {
    Branch branch = branch();
    SVNRepository repository = repository();
    SCMBuildView<SVNHistory> scmBuildFrom = new SCMBuildView<>(BuildView.of(Build.of(branch, new NameDescription("10", "Build 10"), Signature.of("user"))), new SVNHistory(new SVNReference("/project/branches/10", "http://server/project/branches/10", 110000, Time.now()), new SVNReference("/project/trunk", "http://server/project/trunk", 100000, Time.now())));
    SCMBuildView<SVNHistory> scmBuildTo = new SCMBuildView<>(BuildView.of(Build.of(branch, new NameDescription("5", "Build 5"), Signature.of("user"))), new SVNHistory(new SVNReference("/project/trunk", "http://server/project/trunk", 90000, Time.now())));
    SVNChangeLog changeLog = new SVNChangeLog(UUID.randomUUID().toString(), branch.getProject(), repository, scmBuildFrom, scmBuildTo);
    // Gets the references
    Collection<SVNChangeLogReference> references = changeLog.getChangeLogReferences();
    // Check
    assertNotNull(references);
    assertEquals(2, references.size());
    Iterator<SVNChangeLogReference> iterator = references.iterator();
    SVNChangeLogReference referenceBranch = iterator.next();
    {
        assertEquals("/project/branches/10", referenceBranch.getPath());
        assertEquals(0, referenceBranch.getStart());
        assertEquals(110000, referenceBranch.getEnd());
    }
    SVNChangeLogReference referenceTrunk = iterator.next();
    {
        assertEquals("/project/trunk", referenceTrunk.getPath());
        assertEquals(90000, referenceTrunk.getStart());
        assertEquals(100000, referenceTrunk.getEnd());
    }
}
Also used : SVNRepository(net.nemerosa.ontrack.extension.svn.db.SVNRepository) SCMBuildView(net.nemerosa.ontrack.extension.scm.model.SCMBuildView) Test(org.junit.Test)

Example 8 with SVNRepository

use of net.nemerosa.ontrack.extension.svn.db.SVNRepository in project ontrack by nemerosa.

the class SVNChangeLogTest method simple.

@Test
public void simple() {
    Branch branch = branch();
    SVNRepository repository = repository();
    SCMBuildView<SVNHistory> scmBuildFrom = new SCMBuildView<>(BuildView.of(Build.of(branch, new NameDescription("10", "Build 10"), Signature.of("user"))), new SVNHistory(new SVNReference("/project/trunk", "http://server/project/trunk", 110000, Time.now())));
    SCMBuildView<SVNHistory> scmBuildTo = new SCMBuildView<>(BuildView.of(Build.of(branch, new NameDescription("20", "Build 20"), Signature.of("user"))), new SVNHistory(new SVNReference("/project/trunk", "http://server/project/trunk", 120000, Time.now())));
    SVNChangeLog changeLog = new SVNChangeLog(UUID.randomUUID().toString(), branch.getProject(), repository, scmBuildFrom, scmBuildTo);
    // Gets the references
    Collection<SVNChangeLogReference> references = changeLog.getChangeLogReferences();
    // Check
    assertNotNull(references);
    assertEquals(1, references.size());
    SVNChangeLogReference reference = references.iterator().next();
    assertEquals("/project/trunk", reference.getPath());
    assertEquals(110000, reference.getStart());
    assertEquals(120000, reference.getEnd());
}
Also used : SVNRepository(net.nemerosa.ontrack.extension.svn.db.SVNRepository) SCMBuildView(net.nemerosa.ontrack.extension.scm.model.SCMBuildView) Test(org.junit.Test)

Example 9 with SVNRepository

use of net.nemerosa.ontrack.extension.svn.db.SVNRepository in project ontrack by nemerosa.

the class SVNChangeLogTest method none.

@Test
public void none() {
    Branch branch = branch();
    SVNRepository repository = repository();
    SCMBuildView<SVNHistory> scmBuildFrom = new SCMBuildView<>(BuildView.of(Build.of(branch, new NameDescription("10", "Build 10"), Signature.of("user"))), new SVNHistory(new SVNReference("/project/trunk", "http://server/project/trunk", 100000, Time.now())));
    SVNChangeLog changeLog = new SVNChangeLog(UUID.randomUUID().toString(), branch.getProject(), repository, scmBuildFrom, scmBuildFrom);
    // Gets the references
    Collection<SVNChangeLogReference> references = changeLog.getChangeLogReferences();
    // Check
    assertNotNull(references);
    assertEquals(1, references.size());
    assertTrue(references.iterator().next().isNone());
}
Also used : SVNRepository(net.nemerosa.ontrack.extension.svn.db.SVNRepository) SCMBuildView(net.nemerosa.ontrack.extension.scm.model.SCMBuildView) Test(org.junit.Test)

Example 10 with SVNRepository

use of net.nemerosa.ontrack.extension.svn.db.SVNRepository in project ontrack by nemerosa.

the class SVNChangeLogServiceImpl method changeLogExportFormats.

@Override
public Collection<ExportFormat> changeLogExportFormats(ID branchId) {
    // Gets the branch
    Branch branch = structureService.getBranch(branchId);
    // Gets the SVN repository
    SVNRepository svnRepository = getSVNRepository(branch);
    ConfiguredIssueService configuredIssueService = svnRepository.getConfiguredIssueService();
    if (configuredIssueService != null) {
        return configuredIssueService.getIssueServiceExtension().exportFormats(configuredIssueService.getIssueServiceConfiguration());
    } else {
        return Collections.emptyList();
    }
}
Also used : ConfiguredIssueService(net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService) SVNRepository(net.nemerosa.ontrack.extension.svn.db.SVNRepository)

Aggregations

SVNRepository (net.nemerosa.ontrack.extension.svn.db.SVNRepository)14 Transaction (net.nemerosa.ontrack.tx.Transaction)6 ConfiguredIssueService (net.nemerosa.ontrack.extension.issues.model.ConfiguredIssueService)3 SCMBuildView (net.nemerosa.ontrack.extension.scm.model.SCMBuildView)3 Test (org.junit.Test)3 Transactional (org.springframework.transaction.annotation.Transactional)3 TCopyEvent (net.nemerosa.ontrack.extension.svn.db.TCopyEvent)2 SVNBranchConfigurationProperty (net.nemerosa.ontrack.extension.svn.property.SVNBranchConfigurationProperty)2 SVNProjectConfigurationProperty (net.nemerosa.ontrack.extension.svn.property.SVNProjectConfigurationProperty)2 SVNURL (org.tmatesoft.svn.core.SVNURL)2 java.util (java.util)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 Collectors (java.util.stream.Collectors)1 EntityInformation (net.nemerosa.ontrack.extension.api.model.EntityInformation)1 Issue (net.nemerosa.ontrack.extension.issues.model.Issue)1 IssueServiceConfigurationRepresentation (net.nemerosa.ontrack.extension.issues.model.IssueServiceConfigurationRepresentation)1 SCMIssueCommitBranchInfo (net.nemerosa.ontrack.extension.scm.model.SCMIssueCommitBranchInfo)1 SCMUtilsService (net.nemerosa.ontrack.extension.scm.service.SCMUtilsService)1 SVNIssueRevisionDao (net.nemerosa.ontrack.extension.svn.db.SVNIssueRevisionDao)1