Search in sources :

Example 11 with InfoScmResult

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;
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmException(org.apache.maven.scm.ScmException) ScmRepositoryException(org.apache.maven.scm.repository.ScmRepositoryException) InfoScmResult(org.apache.maven.scm.command.info.InfoScmResult) CommandParameters(org.apache.maven.scm.CommandParameters) File(java.io.File)

Example 12 with InfoScmResult

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();
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmRepositoryException(org.apache.maven.scm.repository.ScmRepositoryException) RemoteInfoScmResult(org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult) InfoScmResult(org.apache.maven.scm.command.info.InfoScmResult) File(java.io.File) SvnInfoCommand(org.apache.maven.scm.provider.svn.svnexe.command.info.SvnInfoCommand)

Example 13 with InfoScmResult

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());
}
Also used : ScmException(org.apache.maven.scm.ScmException) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) SvnCommandLineUtils(org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils) InfoScmResult(org.apache.maven.scm.command.info.InfoScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Aggregations

InfoScmResult (org.apache.maven.scm.command.info.InfoScmResult)13 ScmFileSet (org.apache.maven.scm.ScmFileSet)7 CommandParameters (org.apache.maven.scm.CommandParameters)5 ScmException (org.apache.maven.scm.ScmException)5 ScmProvider (org.apache.maven.scm.provider.ScmProvider)4 ScmProviderRepository (org.apache.maven.scm.provider.ScmProviderRepository)4 File (java.io.File)3 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)3 ScmResult (org.apache.maven.scm.ScmResult)2 InfoItem (org.apache.maven.scm.command.info.InfoItem)2 SvnCommandLineUtils (org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils)2 ScmRepositoryException (org.apache.maven.scm.repository.ScmRepositoryException)2 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)2 Commandline (org.codehaus.plexus.util.cli.Commandline)2 RemoteInfoScmResult (org.apache.maven.scm.command.remoteinfo.RemoteInfoScmResult)1 DefaultLog (org.apache.maven.scm.log.DefaultLog)1 GitCommandLineUtils (org.apache.maven.scm.provider.git.gitexe.command.GitCommandLineUtils)1 HgInfoCommand (org.apache.maven.scm.provider.hg.command.info.HgInfoCommand)1 SvnInfoCommand (org.apache.maven.scm.provider.svn.svnexe.command.info.SvnInfoCommand)1 SvnInfoCommandExpanded (org.apache.maven.scm.provider.svn.svnexe.command.info.SvnInfoCommandExpanded)1