use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class AccuRevCommandLineTest method testAnnotate.
@Test
public void testAnnotate() throws Exception {
File basedir = new File("/my/workspace");
File file = new File("src/main/java/foo.java");
AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
accuRevCL.annotate(basedir, file);
Commandline lastCL = accuRevCL.getCommandline();
assertThat(lastCL.getWorkingDirectory(), is(basedir.getCanonicalFile()));
assertThat(lastCL.getArguments(), is(new String[] { "annotate", "-ftud", file.getPath() }));
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class AccuRevCommandLineTest method testStatBackingStream.
@Test
public void testStatBackingStream() throws Exception {
AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
File basedir = new File("/my/workspace");
List<File> elements = new ArrayList<File>(1);
File addedOrModifiedFile = new File("addedOrModified/file");
elements.add(addedOrModifiedFile);
accuRevCL.statBackingStream(basedir, elements);
Commandline lastCL = accuRevCL.getCommandline();
assertThat(lastCL.getWorkingDirectory(), is(basedir.getCanonicalFile()));
assertThat(lastCL.getArguments(), is(new String[] { "stat", "-b", "-ffr", addedOrModifiedFile.getPath() }));
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class SvnRemoveCommand method createCommandLine.
private static Commandline createCommandLine(File workingDirectory, List<File> files) throws ScmException {
// Base command line doesn't make sense here - username/password not needed, and non-interactive/non-recusive is
// not valid
Commandline cl = new Commandline();
cl.setExecutable("svn");
cl.setWorkingDirectory(workingDirectory.getAbsolutePath());
cl.createArg().setValue("remove");
try {
SvnCommandLineUtils.addTarget(cl, files);
} catch (IOException e) {
throw new ScmException("Can't create the targets file", e);
}
return cl;
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class SvnStatusCommand method executeStatusCommand.
/**
* {@inheritDoc}
*/
protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
Commandline cl = createCommandLine((SvnScmProviderRepository) repo, fileSet);
SvnStatusConsumer consumer = new SvnStatusConsumer(getLogger(), fileSet.getBasedir());
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 StatusScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
}
return new StatusScmResult(cl.toString(), consumer.getChangedFiles());
}
use of org.codehaus.plexus.util.cli.Commandline in project maven-scm by apache.
the class SvnTagCommand method createCommandLine.
public static Commandline createCommandLine(SvnScmProviderRepository repository, File workingDirectory, String tag, File messageFile, ScmTagParameters scmTagParameters) {
Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine(workingDirectory, repository);
cl.createArg().setValue("copy");
cl.createArg().setValue("--file");
cl.createArg().setValue(messageFile.getAbsolutePath());
cl.createArg().setValue("--parents");
if (scmTagParameters != null && scmTagParameters.getScmRevision() != null) {
cl.createArg().setValue("--revision");
cl.createArg().setValue(scmTagParameters.getScmRevision());
}
if (scmTagParameters != null && scmTagParameters.isRemoteTagging()) {
cl.createArg().setValue(SvnCommandUtils.fixUrl(repository.getUrl(), repository.getUser()));
} else {
cl.createArg().setValue(".");
}
// Note: this currently assumes you have the tag base checked out too
String tagUrl = SvnTagBranchUtils.resolveTagUrl(repository, new ScmTag(tag));
cl.createArg().setValue(SvnCommandUtils.fixUrl(tagUrl, repository.getUser()));
return cl;
}
Aggregations