use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class AccuRevAddCommandTest method testAdd.
@Test
public void testAdd() throws Exception {
final ScmFileSet testFileSet = new ScmFileSet(basedir, new File("src/main/java/Foo.java"));
final List<File> files = testFileSet.getFileList();
when(accurev.add(basedir, files, "A new file")).thenReturn(Collections.singletonList(new File("added/file")));
AccuRevAddCommand command = new AccuRevAddCommand(getLogger());
CommandParameters commandParameters = new CommandParameters();
commandParameters.setString(CommandParameter.MESSAGE, "A new file");
AddScmResult result = command.add(repo, testFileSet, commandParameters);
assertThat(result.isSuccess(), is(true));
assertThat(result.getAddedFiles().size(), is(1));
assertHasScmFile(result.getAddedFiles(), "added/file", ScmFileStatus.ADDED);
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class JGitCheckInCommandCommitterAuthorTckTest method createAndCommitFile.
private void createAndCommitFile(File file, String username) throws Exception, ScmException, IOException {
createFooJava(file);
ScmRepository scmRepository = getScmRepository();
scmRepository.getProviderRepository().setUser(username);
AddScmResult addResult = getScmManager().add(scmRepository, new ScmFileSet(getWorkingCopy(), "**/*.java"));
assertResultIsSuccess(addResult);
CheckInScmResult result = getScmManager().checkIn(scmRepository, new ScmFileSet(getWorkingCopy(), "**/Foo.java"), "Commit message");
assertResultIsSuccess(result);
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class SvnAddCommand method executeAddCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeAddCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
// TODO: could do this with propset?
if (binary) {
throw new ScmException("This provider does not yet support binary files");
}
if (fileSet.getFileList().isEmpty()) {
throw new ScmException("You must provide at least one file/directory to add");
}
Commandline cl = createCommandLine(fileSet.getBasedir(), fileSet.getFileList());
SvnAddConsumer consumer = new SvnAddConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
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 AddScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
}
return new AddScmResult(cl.toString(), consumer.getAddedFiles());
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class ScmTckTestCase method addToWorkingTree.
/**
* Convenience method to add a file to the working tree at the working directory
*/
protected void addToWorkingTree(File workingDirectory, File file, ScmRepository repository) throws Exception {
ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl());
CommandParameters commandParameters = new CommandParameters();
commandParameters.setString(CommandParameter.FORCE_ADD, Boolean.TRUE.toString());
AddScmResult result = provider.add(repository, new ScmFileSet(workingDirectory, file), commandParameters);
assertTrue("Check result was successful, output: " + result.getCommandOutput(), result.isSuccess());
List<ScmFile> addedFiles = result.getAddedFiles();
if (new File(workingDirectory, file.getPath()).isFile()) {
// Don't check directory add because some SCM tools ignore it
assertEquals("Expected 1 file in the added files list " + addedFiles, 1, addedFiles.size());
}
}
use of org.apache.maven.scm.command.add.AddScmResult in project maven-scm by apache.
the class PerforceScmProvider method add.
public AddScmResult add(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
PerforceAddCommand command = new PerforceAddCommand();
command.setLogger(getLogger());
return (AddScmResult) command.execute(repository, fileSet, params);
}
Aggregations