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);
}
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);
}
}
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);
}
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());
}
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);
}
Aggregations