Search in sources :

Example 36 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class SynergyStatusCommand method executeStatusCommand.

/**
 * {@inheritDoc}
 */
protected StatusScmResult executeStatusCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing status command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("basedir: " + fileSet.getBasedir());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    List<String> l;
    try {
        l = SynergyUtil.getWorkingFiles(getLogger(), repo.getProjectSpec(), repo.getProjectRelease(), ccmAddr);
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    List<ScmFile> result = new LinkedList<ScmFile>();
    for (String filename : l) {
        ScmFile f = new ScmFile(filename, ScmFileStatus.MODIFIED);
        result.add(f);
    }
    return new StatusScmResult("ccm dir", result);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) LinkedList(java.util.LinkedList) ScmFile(org.apache.maven.scm.ScmFile)

Example 37 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class StatusMojo method execute.

/**
 * {@inheritDoc}
 */
public void execute() throws MojoExecutionException {
    super.execute();
    try {
        ScmRepository repository = getScmRepository();
        StatusScmResult result = getScmManager().status(repository, getFileSet());
        checkResult(result);
        File baseDir = getFileSet().getBasedir();
        // Determine the maximum length of the status column
        int maxLen = 0;
        for (ScmFile file : result.getChangedFiles()) {
            maxLen = Math.max(maxLen, file.getStatus().toString().length());
        }
        for (ScmFile file : result.getChangedFiles()) {
            // right align all of the statuses
            getLog().info(StringUtils.leftPad(file.getStatus().toString(), maxLen) + " status for " + getRelativePath(baseDir, file.getPath()));
        }
    } catch (IOException e) {
        throw new MojoExecutionException("Cannot run status command : ", e);
    } catch (ScmException e) {
        throw new MojoExecutionException("Cannot run status command : ", e);
    }
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmException(org.apache.maven.scm.ScmException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 38 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class PerforceStatusCommand method executeStatusCommand.

/**
 * {@inheritDoc}
 */
protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet files) throws ScmException {
    PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
    actualLocation = PerforceScmProvider.getRepoPath(getLogger(), prepo, files.getBasedir());
    PerforceStatusConsumer consumer = new PerforceStatusConsumer();
    Commandline command = readOpened(prepo, files, consumer);
    if (consumer.isSuccess()) {
        List<ScmFile> scmfiles = createResults(actualLocation, consumer);
        return new StatusScmResult(command.toString(), scmfiles);
    }
    return new StatusScmResult(command.toString(), "Unable to get status", consumer.getOutput(), consumer.isSuccess());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) Commandline(org.codehaus.plexus.util.cli.Commandline) PerforceScmProviderRepository(org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository) ScmFile(org.apache.maven.scm.ScmFile)

Example 39 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class PerforceScmProvider method status.

protected StatusScmResult status(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
    PerforceStatusCommand command = new PerforceStatusCommand();
    command.setLogger(getLogger());
    return (StatusScmResult) command.execute(repository, fileSet, params);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) PerforceStatusCommand(org.apache.maven.scm.provider.perforce.command.status.PerforceStatusCommand)

Example 40 with StatusScmResult

use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.

the class GitStatusCommand method executeStatusCommand.

/**
 * {@inheritDoc}
 */
protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
    Commandline clRevparse = createRevparseShowToplevelCommand(fileSet);
    CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    URI relativeRepositoryPath = null;
    int exitCode;
    exitCode = GitCommandLineUtils.execute(clRevparse, stdout, stderr, getLogger());
    if (exitCode != 0) {
        // git-status returns non-zero if nothing to do
        if (getLogger().isInfoEnabled()) {
            getLogger().info("Could not resolve toplevel");
        }
    } else {
        relativeRepositoryPath = GitStatusConsumer.resolveURI(stdout.getOutput().trim(), fileSet.getBasedir().toURI());
    }
    Commandline cl = createCommandLine((GitScmProviderRepository) repo, fileSet);
    GitStatusConsumer consumer = new GitStatusConsumer(getLogger(), fileSet.getBasedir(), relativeRepositoryPath);
    stderr = new CommandLineUtils.StringStreamConsumer();
    exitCode = GitCommandLineUtils.execute(cl, consumer, stderr, getLogger());
    if (exitCode != 0) {
        // git-status returns non-zero if nothing to do
        if (getLogger().isInfoEnabled()) {
            getLogger().info("nothing added to commit but untracked files present (use \"git add\" to track)");
        }
    }
    return new StatusScmResult(cl.toString(), consumer.getChangedFiles());
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) Commandline(org.codehaus.plexus.util.cli.Commandline) GitCommandLineUtils(org.apache.maven.scm.provider.git.gitexe.command.GitCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) URI(java.net.URI)

Aggregations

StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)40 ScmFile (org.apache.maven.scm.ScmFile)15 ScmException (org.apache.maven.scm.ScmException)14 File (java.io.File)12 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)9 Commandline (org.codehaus.plexus.util.cli.Commandline)9 ArrayList (java.util.ArrayList)6 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)6 ScmResult (org.apache.maven.scm.ScmResult)5 ScmFileSet (org.apache.maven.scm.ScmFileSet)4 JazzScmCommand (org.apache.maven.scm.provider.jazz.command.JazzScmCommand)3 ErrorConsumer (org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer)3 JazzStatusCommand (org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand)3 ScmRepository (org.apache.maven.scm.repository.ScmRepository)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 CommandParameters (org.apache.maven.scm.CommandParameters)2 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)2 CategorisedElements (org.apache.maven.scm.provider.accurev.CategorisedElements)2 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)2 BazaarStatusCommand (org.apache.maven.scm.provider.bazaar.command.status.BazaarStatusCommand)2