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;
}
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");
});
}
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();
});
}
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;
}
Aggregations