Search in sources :

Example 11 with ListScmResult

use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.

the class ListCommandTckTest method runList.

private List<ScmFile> runList(ScmFileSet fileSet, boolean recursive) throws Exception {
    ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl());
    ListScmResult result = provider.list(getScmRepository(), fileSet, recursive, (ScmVersion) null);
    assertTrue("SCM command failed: " + result.getCommandLine() + " : " + result.getProviderMessage() + (result.getCommandOutput() == null ? "" : ": " + result.getCommandOutput()), result.isSuccess());
    return result.getFiles();
}
Also used : ScmProvider(org.apache.maven.scm.provider.ScmProvider) ListScmResult(org.apache.maven.scm.command.list.ListScmResult)

Example 12 with ListScmResult

use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.

the class GitListCommand method executeListCommand.

/**
 * {@inheritDoc}
 */
protected ListScmResult executeListCommand(ScmProviderRepository repo, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion) throws ScmException {
    GitScmProviderRepository repository = (GitScmProviderRepository) repo;
    if (GitScmProviderRepository.PROTOCOL_FILE.equals(repository.getFetchInfo().getProtocol()) && repository.getFetchInfo().getPath().indexOf(fileSet.getBasedir().getPath()) >= 0) {
        throw new ScmException("remote repository must not be the working directory");
    }
    int exitCode;
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    GitListConsumer consumer = new GitListConsumer(getLogger(), fileSet.getBasedir().getParentFile(), ScmFileStatus.CHECKED_IN);
    Commandline cl = createCommandLine(repository, fileSet.getBasedir());
    exitCode = GitCommandLineUtils.execute(cl, consumer, stderr, getLogger());
    if (exitCode != 0) {
        return new ListScmResult(cl.toString(), "The git-ls-files command failed.", stderr.getOutput(), false);
    }
    return new ListScmResult(cl.toString(), consumer.getListedFiles());
}
Also used : ScmException(org.apache.maven.scm.ScmException) GitScmProviderRepository(org.apache.maven.scm.provider.git.repository.GitScmProviderRepository) Commandline(org.codehaus.plexus.util.cli.Commandline) GitCommandLineUtils(org.apache.maven.scm.provider.git.gitexe.command.GitCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) ListScmResult(org.apache.maven.scm.command.list.ListScmResult)

Example 13 with ListScmResult

use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.

the class TfsScmProvider method list.

protected ListScmResult list(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    TfsListCommand command = new TfsListCommand();
    command.setLogger(getLogger());
    return (ListScmResult) command.execute(repository, fileSet, parameters);
}
Also used : ListScmResult(org.apache.maven.scm.command.list.ListScmResult) TfsListCommand(org.apache.maven.scm.provider.tfs.command.TfsListCommand)

Example 14 with ListScmResult

use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.

the class CvsExeListCommand method executeCvsCommand.

/**
 * {@inheritDoc}
 */
protected ListScmResult executeCvsCommand(Commandline cl) throws ScmException {
    CvsListConsumer consumer = new CvsListConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    try {
        exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
    } catch (CommandLineException ex) {
        throw new ScmException("Error while executing command.", ex);
    }
    if (exitCode != 0) {
        return new ListScmResult(cl.toString(), "The cvs command failed.", stderr.getOutput(), false);
    }
    return new ListScmResult(cl.toString(), consumer.getEntries());
}
Also used : ScmException(org.apache.maven.scm.ScmException) CvsListConsumer(org.apache.maven.scm.provider.cvslib.command.list.CvsListConsumer) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) ListScmResult(org.apache.maven.scm.command.list.ListScmResult) CommandLineException(org.codehaus.plexus.util.cli.CommandLineException)

Example 15 with ListScmResult

use of org.apache.maven.scm.command.list.ListScmResult in project maven-scm by apache.

the class SvnMkdirCommandTckTest method testMkdirCommandDirAlreadyAdded.

public void testMkdirCommandDirAlreadyAdded() throws Exception {
    ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File(getMissingDirectory()));
    MkdirScmResult result = getScmManager().mkdir(getScmRepository(), fileSet, null, false);
    assertResultIsSuccess(result);
    assertNotNull(result.getRevision());
    ListScmResult listResult = getScmManager().list(getScmRepository(), fileSet, true, null);
    assertTrue("Directory should have been found.", listResult.isSuccess());
    // add the directory again
    result = getScmManager().mkdir(getScmRepository(), fileSet, null, false);
    printOutputError(result);
    assertFalse(result.isSuccess());
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) MkdirScmResult(org.apache.maven.scm.command.mkdir.MkdirScmResult) ListScmResult(org.apache.maven.scm.command.list.ListScmResult) File(java.io.File)

Aggregations

ListScmResult (org.apache.maven.scm.command.list.ListScmResult)22 ScmException (org.apache.maven.scm.ScmException)8 File (java.io.File)7 ScmFile (org.apache.maven.scm.ScmFile)5 ScmFileSet (org.apache.maven.scm.ScmFileSet)5 MkdirScmResult (org.apache.maven.scm.command.mkdir.MkdirScmResult)4 ArrayList (java.util.ArrayList)3 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)3 ScmResult (org.apache.maven.scm.ScmResult)2 ScmProvider (org.apache.maven.scm.provider.ScmProvider)2 CvsListConsumer (org.apache.maven.scm.provider.cvslib.command.list.CvsListConsumer)2 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)2 Commandline (org.codehaus.plexus.util.cli.Commandline)2 APIException (com.mks.api.response.APIException)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 CvsLogListener (org.apache.maven.scm.provider.cvslib.cvsjava.util.CvsLogListener)1