Search in sources :

Example 1 with SVNStatus

use of org.tmatesoft.svn.core.wc.SVNStatus in project spring-cloud-config by spring-cloud.

the class SvnKitEnvironmentRepository method update.

private String update(SvnOperationFactory svnOperationFactory, String label) throws SVNException {
    logger.debug("Repo already checked out - updating instead.");
    try {
        final SvnUpdate update = svnOperationFactory.createUpdate();
        update.setSingleTarget(SvnTarget.fromFile(getWorkingDirectory()));
        long[] ids = update.run();
        StringBuilder version = new StringBuilder();
        for (long id : ids) {
            if (version.length() > 0) {
                version.append(",");
            }
            version.append(id);
        }
        return version.toString();
    } catch (Exception e) {
        String message = "Could not update remote for " + label + " (current local=" + getWorkingDirectory().getPath() + "), remote: " + this.getUri() + ")";
        if (logger.isDebugEnabled()) {
            logger.debug(message, e);
        } else if (logger.isWarnEnabled()) {
            logger.warn(message);
        }
    }
    final SVNStatus status = SVNClientManager.newInstance().getStatusClient().doStatus(getWorkingDirectory(), false);
    return status != null ? status.getRevision().toString() : null;
}
Also used : SVNStatus(org.tmatesoft.svn.core.wc.SVNStatus) SvnUpdate(org.tmatesoft.svn.core.wc2.SvnUpdate) SVNException(org.tmatesoft.svn.core.SVNException)

Example 2 with SVNStatus

use of org.tmatesoft.svn.core.wc.SVNStatus in project sonarqube by SonarSource.

the class SvnBlameCommandTest method blame_givenNoCredentials_logWarning.

@Test
public void blame_givenNoCredentials_logWarning() throws Exception {
    BlameOutput output = mock(BlameOutput.class);
    InputFile inputFile = mock(InputFile.class);
    SvnBlameCommand svnBlameCommand = newSvnBlameCommand();
    SVNClientManager clientManager = mock(SVNClientManager.class);
    SVNLogClient logClient = mock(SVNLogClient.class);
    SVNStatusClient statusClient = mock(SVNStatusClient.class);
    SVNStatus status = mock(SVNStatus.class);
    when(clientManager.getLogClient()).thenReturn(logClient);
    when(clientManager.getStatusClient()).thenReturn(statusClient);
    when(status.getContentsStatus()).thenReturn(SVNStatusType.STATUS_NORMAL);
    when(inputFile.file()).thenReturn(mock(File.class));
    when(statusClient.doStatus(any(File.class), anyBoolean())).thenReturn(status);
    doThrow(SVNAuthenticationException.class).when(logClient).doAnnotate(any(File.class), any(SVNRevision.class), any(SVNRevision.class), any(SVNRevision.class), anyBoolean(), anyBoolean(), any(AnnotationHandler.class), eq(null));
    assertThrows(IllegalStateException.class, () -> {
        svnBlameCommand.blame(clientManager, inputFile, output);
        assertThat(logTester.logs(LoggerLevel.WARN)).contains("Authentication to SVN server is required but no " + "authentication data was passed to the scanner");
    });
}
Also used : SVNStatus(org.tmatesoft.svn.core.wc.SVNStatus) SVNStatusClient(org.tmatesoft.svn.core.wc.SVNStatusClient) BlameOutput(org.sonar.api.batch.scm.BlameCommand.BlameOutput) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) ZipFile(java.util.zip.ZipFile) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) Test(org.junit.Test)

Example 3 with SVNStatus

use of org.tmatesoft.svn.core.wc.SVNStatus in project sonarqube by SonarSource.

the class SvnBlameCommandTest method blame_givenCredentialsSupplied_doNotlogWarning.

@Test
public void blame_givenCredentialsSupplied_doNotlogWarning() throws Exception {
    BlameOutput output = mock(BlameOutput.class);
    InputFile inputFile = mock(InputFile.class);
    SvnConfiguration properties = mock(SvnConfiguration.class);
    SvnBlameCommand svnBlameCommand = new SvnBlameCommand(properties);
    SVNClientManager clientManager = mock(SVNClientManager.class);
    SVNLogClient logClient = mock(SVNLogClient.class);
    SVNStatusClient statusClient = mock(SVNStatusClient.class);
    SVNStatus status = mock(SVNStatus.class);
    when(properties.isEmpty()).thenReturn(true);
    when(clientManager.getLogClient()).thenReturn(logClient);
    when(clientManager.getStatusClient()).thenReturn(statusClient);
    when(status.getContentsStatus()).thenReturn(SVNStatusType.STATUS_NORMAL);
    when(inputFile.file()).thenReturn(mock(File.class));
    when(statusClient.doStatus(any(File.class), anyBoolean())).thenReturn(status);
    doThrow(SVNAuthenticationException.class).when(logClient).doAnnotate(any(File.class), any(SVNRevision.class), any(SVNRevision.class), any(SVNRevision.class), anyBoolean(), anyBoolean(), any(AnnotationHandler.class), eq(null));
    assertThrows(IllegalStateException.class, () -> {
        svnBlameCommand.blame(clientManager, inputFile, output);
        assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty();
    });
}
Also used : SVNStatus(org.tmatesoft.svn.core.wc.SVNStatus) SVNStatusClient(org.tmatesoft.svn.core.wc.SVNStatusClient) BlameOutput(org.sonar.api.batch.scm.BlameCommand.BlameOutput) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) ZipFile(java.util.zip.ZipFile) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) SVNClientManager(org.tmatesoft.svn.core.wc.SVNClientManager) SVNLogClient(org.tmatesoft.svn.core.wc.SVNLogClient) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) Test(org.junit.Test)

Example 4 with SVNStatus

use of org.tmatesoft.svn.core.wc.SVNStatus in project intellij-community by JetBrains.

the class Status method create.

@Nullable
public static Status create(@Nullable SVNStatus status) {
    Status result = null;
    if (status != null) {
        result = new Status(status.getURL(), status.getFile(), NodeKind.from(status.getKind()), status.getRevision(), status.getCommittedRevision(), StatusType.from(status.getContentsStatus()), StatusType.from(status.getPropertiesStatus()), StatusType.from(status.getRemoteContentsStatus()), StatusType.from(status.getRemotePropertiesStatus()), status.isLocked(), status.isCopied(), status.isSwitched(), status.getCopyFromURL(), Lock.create(status.getRemoteLock()), Lock.create(status.getLocalLock()), status.getChangelistName(), TreeConflictDescription.create(status.getTreeConflict()));
        result.setIsConflicted(status.isConflicted());
        result.setNodeStatus(StatusType.from(status.getNodeStatus()));
        result.setRemoteNodeStatus(StatusType.from(status.getRemoteNodeStatus()));
        result.setRemoteRevision(status.getRemoteRevision());
        result.setRepositoryRootURL(status.getRepositoryRootURL());
    }
    return result;
}
Also used : SVNStatus(org.tmatesoft.svn.core.wc.SVNStatus) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

SVNStatus (org.tmatesoft.svn.core.wc.SVNStatus)4 File (java.io.File)2 ZipFile (java.util.zip.ZipFile)2 Test (org.junit.Test)2 InputFile (org.sonar.api.batch.fs.InputFile)2 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)2 BlameOutput (org.sonar.api.batch.scm.BlameCommand.BlameOutput)2 SVNClientManager (org.tmatesoft.svn.core.wc.SVNClientManager)2 SVNLogClient (org.tmatesoft.svn.core.wc.SVNLogClient)2 SVNRevision (org.tmatesoft.svn.core.wc.SVNRevision)2 SVNStatusClient (org.tmatesoft.svn.core.wc.SVNStatusClient)2 Nullable (org.jetbrains.annotations.Nullable)1 SVNException (org.tmatesoft.svn.core.SVNException)1 SvnUpdate (org.tmatesoft.svn.core.wc2.SvnUpdate)1