use of org.apache.maven.scm.command.info.InfoScmResult in project maven-scm by apache.
the class AbstractSvnScmProvider method makeProviderScmRepository.
/**
* {@inheritDoc}
*/
public ScmProviderRepository makeProviderScmRepository(String scmSpecificUrl, char delimiter) throws ScmRepositoryException {
ScmUrlParserResult result = parseScmUrl(scmSpecificUrl);
if (checkWorkingDirectoryUrl()) {
getLogger().debug("Checking svn info 'URL:' field matches current sources directory");
try {
String workingDir = System.getProperty("scmCheckWorkingDirectoryUrl.currentWorkingDirectory");
InfoScmResult info = info(result.repository, new ScmFileSet(new File(workingDir)), new CommandParameters());
String url = findUrlInfoItem(info);
String comparison = "'" + url + "' vs. '" + scmSpecificUrl + "'";
getLogger().debug("Comparing : " + comparison);
if (url != null && !url.equals(scmSpecificUrl)) {
result.messages.add("Scm url does not match the value returned by svn info (" + comparison + ")");
}
} catch (ScmException e) {
throw new ScmRepositoryException("An error occurred while trying to svn info", e);
}
}
if (result.messages.size() > 0) {
throw new ScmRepositoryException("The scm url is invalid.", result.messages);
}
return result.repository;
}
use of org.apache.maven.scm.command.info.InfoScmResult in project maven-scm by apache.
the class SvnExeScmProvider method getRepositoryURL.
/**
* {@inheritDoc}
*/
protected String getRepositoryURL(File path) throws ScmException {
// Note: I need to supply just 1 absolute path, but ScmFileSet won't let me without
// a basedir (which isn't used here anyway), so use a dummy file.
SvnInfoCommand infoCmd = (SvnInfoCommand) getInfoCommand();
infoCmd.setLogger(this.getLogger());
InfoScmResult result = infoCmd.executeInfoCommand(null, new ScmFileSet(new File(""), path), null, false, null);
if (result.getInfoItems().size() != 1) {
throw new ScmRepositoryException("Cannot find URL: " + (result.getInfoItems().size() == 0 ? "no" : "multiple") + " items returned by the info command");
}
return result.getInfoItems().get(0).getURL();
}
use of org.apache.maven.scm.command.info.InfoScmResult in project maven-plugins by apache.
the class SvnInfoCommandExpanded method executeInfoCommand.
private InfoScmResult executeInfoCommand(final Commandline cl) throws ScmException {
SvnInfoConsumer consumer = new SvnInfoConsumer();
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
int exitCode;
try {
exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
return new InfoScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
}
return new InfoScmResult(cl.toString(), consumer.getInfoItems());
}
Aggregations