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