Search in sources :

Example 16 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class StarteamScmProvider method remove.

/**
 * {@inheritDoc}
 */
public RemoveScmResult remove(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    fileSet = fixUpScmFileSetAbsoluteFilePath(fileSet);
    StarteamRemoveCommand command = new StarteamRemoveCommand();
    command.setLogger(getLogger());
    return (RemoveScmResult) command.execute(repository, fileSet, parameters);
}
Also used : StarteamRemoveCommand(org.apache.maven.scm.provider.starteam.command.remove.StarteamRemoveCommand) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult)

Example 17 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class RemoveMojo method execute.

/**
 * {@inheritDoc}
 */
public void execute() throws MojoExecutionException {
    super.execute();
    try {
        ScmRepository repository = getScmRepository();
        RemoveScmResult result = getScmManager().remove(repository, getFileSet(), message);
        checkResult(result);
    } catch (IOException e) {
        throw new MojoExecutionException("Cannot run remove command : " + e.getMessage(), e);
    } catch (ScmException e) {
        throw new MojoExecutionException("Cannot run remove command : " + e.getMessage(), e);
    }
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmException(org.apache.maven.scm.ScmException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) IOException(java.io.IOException) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult)

Example 18 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class PerforceScmProvider method remove.

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

Example 19 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class GitRemoveCommand method executeRemoveCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeRemoveCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message) throws ScmException {
    if (fileSet.getFileList().isEmpty()) {
        throw new ScmException("You must provide at least one file/directory to remove");
    }
    Commandline cl = createCommandLine(fileSet.getBasedir(), fileSet.getFileList());
    GitRemoveConsumer consumer = new GitRemoveConsumer(getLogger());
    CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
    int exitCode;
    exitCode = GitCommandLineUtils.execute(cl, consumer, stderr, getLogger());
    if (exitCode != 0) {
        return new RemoveScmResult(cl.toString(), "The git command failed.", stderr.getOutput(), false);
    }
    return new RemoveScmResult(cl.toString(), consumer.getRemovedFiles());
}
Also used : ScmException(org.apache.maven.scm.ScmException) Commandline(org.codehaus.plexus.util.cli.Commandline) GitCommandLineUtils(org.apache.maven.scm.provider.git.gitexe.command.GitCommandLineUtils) CommandLineUtils(org.codehaus.plexus.util.cli.CommandLineUtils) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult)

Example 20 with RemoveScmResult

use of org.apache.maven.scm.command.remove.RemoveScmResult in project maven-scm by apache.

the class GitCheckInCommandTest method testCheckinAfterRename.

// Test reproducing SCM-694
public void testCheckinAfterRename() throws Exception {
    File repo = getRepositoryRoot();
    File checkedOutRepo = getWorkingCopy();
    GitScmTestUtils.initRepo("src/test/resources/repository/", getRepositoryRoot(), getWorkingDirectory());
    ScmRepository scmRepository = getScmManager().makeScmRepository("scm:git:file://" + repo.getAbsolutePath());
    checkoutRepoInto(checkedOutRepo, scmRepository);
    // Creating foo/bar/wine.xml
    File fooDir = new File(checkedOutRepo.getAbsolutePath() + File.separator + "foo");
    fooDir.mkdir();
    File barDir = new File(fooDir.getAbsolutePath() + File.separator + "bar");
    barDir.mkdir();
    File wineFile = new File(barDir.getAbsolutePath() + File.separator + "wine.xml");
    FileUtils.fileWrite(wineFile.getAbsolutePath(), "Lacoste castle");
    // Adding and commiting file
    AddScmResult addResult = getScmManager().add(scmRepository, new ScmFileSet(checkedOutRepo, new File("foo/bar/wine.xml")));
    assertResultIsSuccess(addResult);
    CheckInScmResult checkInScmResult = getScmManager().checkIn(scmRepository, new ScmFileSet(checkedOutRepo), "Created wine file");
    assertResultIsSuccess(checkInScmResult);
    // Cloning foo/bar/wine.xml to foo/newbar/wine.xml
    File newBarDir = new File(fooDir.getAbsolutePath() + File.separator + "newbar");
    newBarDir.mkdir();
    File movedWineFile = new File(newBarDir.getAbsolutePath() + File.separator + "wine.xml");
    FileUtils.copyFile(wineFile, movedWineFile);
    // Removing old file, adding new file and commiting...
    RemoveScmResult removeResult = getScmManager().remove(scmRepository, new ScmFileSet(checkedOutRepo, new File("foo/bar/")), "");
    assertResultIsSuccess(removeResult);
    addResult = getScmManager().add(scmRepository, new ScmFileSet(checkedOutRepo, new File("foo/newbar/wine.xml")));
    assertResultIsSuccess(addResult);
    checkInScmResult = getScmManager().checkIn(scmRepository, new ScmFileSet(checkedOutRepo), "moved wine.xml from foo/bar/ to foo/newbar/");
    assertResultIsSuccess(checkInScmResult);
    assertTrue("Renamed file has not been commited !", checkInScmResult.getCheckedInFiles().size() != 0);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmFileSet(org.apache.maven.scm.ScmFileSet) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) File(java.io.File) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult)

Aggregations

RemoveScmResult (org.apache.maven.scm.command.remove.RemoveScmResult)20 File (java.io.File)7 ScmException (org.apache.maven.scm.ScmException)6 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)5 ScmFileSet (org.apache.maven.scm.ScmFileSet)4 Commandline (org.codehaus.plexus.util.cli.Commandline)4 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)3 CommandParameters (org.apache.maven.scm.CommandParameters)2 ScmFileMatcher.assertHasScmFile (org.apache.maven.scm.ScmFileMatcher.assertHasScmFile)2 ScmResult (org.apache.maven.scm.ScmResult)2 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)2 ScmRepository (org.apache.maven.scm.repository.ScmRepository)2 Test (org.junit.Test)2 APIException (com.mks.api.response.APIException)1 Response (com.mks.api.response.Response)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