use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class AccuRevStatusCommandTest method testFailure.
@Test
public void testFailure() throws Exception {
final ScmFileSet testFileSet = getScmFileSet();
when(accurev.stat(basedir, testFileSet.getFileList(), AccuRevStat.MODIFIED)).thenReturn(null);
AccuRevStatusCommand command = new AccuRevStatusCommand(getLogger());
CommandParameters commandParameters = new CommandParameters();
StatusScmResult result = command.status(repo, testFileSet, commandParameters);
assertThat(result.isSuccess(), is(false));
assertThat(result.getProviderMessage(), notNullValue());
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class BazaarCheckInCommand method executeCheckInCommand.
/**
* {@inheritDoc}
*/
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException {
if (version != null && StringUtils.isNotEmpty(version.getName())) {
throw new ScmException("This provider can't handle tags.");
}
// Get files that will be committed (if not specified in fileSet)
List<ScmFile> commitedFiles = new ArrayList<ScmFile>();
List<File> files = fileSet.getFileList();
if (files.isEmpty()) {
// Either commit all changes
BazaarStatusCommand statusCmd = new BazaarStatusCommand();
statusCmd.setLogger(getLogger());
StatusScmResult status = statusCmd.executeStatusCommand(repo, fileSet);
List<ScmFile> statusFiles = status.getChangedFiles();
for (ScmFile file : statusFiles) {
if (file.getStatus() == ScmFileStatus.ADDED || file.getStatus() == ScmFileStatus.DELETED || file.getStatus() == ScmFileStatus.MODIFIED) {
commitedFiles.add(new ScmFile(file.getPath(), ScmFileStatus.CHECKED_IN));
}
}
} else {
// Or commit spesific files
for (File file : files) {
commitedFiles.add(new ScmFile(file.getPath(), ScmFileStatus.CHECKED_IN));
}
}
// Commit to local branch
String[] commitCmd = new String[] { BazaarConstants.COMMIT_CMD, BazaarConstants.MESSAGE_OPTION, message };
commitCmd = BazaarUtils.expandCommandLine(commitCmd, fileSet);
ScmResult result = BazaarUtils.execute(new BazaarConsumer(getLogger()), getLogger(), fileSet.getBasedir(), commitCmd);
// Push to parent branch if any
BazaarScmProviderRepository repository = (BazaarScmProviderRepository) repo;
if (!repository.getURI().equals(fileSet.getBasedir().getAbsolutePath()) && repo.isPushChanges()) {
String[] pushCmd = new String[] { BazaarConstants.PUSH_CMD, BazaarConstants.NO_STRICT_OPTION, repository.getURI() };
result = BazaarUtils.execute(new BazaarConsumer(getLogger()), getLogger(), fileSet.getBasedir(), pushCmd);
}
return new CheckInScmResult(commitedFiles, result);
}
use of org.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class BazaarStatusCommand method executeStatusCommand.
/**
* {@inheritDoc}
*/
public StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
File workingDir = fileSet.getBasedir();
BazaarStatusConsumer consumer = new BazaarStatusConsumer(getLogger(), workingDir);
String[] statusCmd = new String[] { BazaarConstants.STATUS_CMD };
ScmResult result = BazaarUtils.execute(consumer, getLogger(), workingDir, statusCmd);
return new StatusScmResult(consumer.getStatus(), result);
}
use of org.apache.maven.scm.command.status.StatusScmResult 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.apache.maven.scm.command.status.StatusScmResult in project maven-scm by apache.
the class JGitStatusCommand method executeStatusCommand.
/**
* {@inheritDoc}
*/
protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException {
Git git = null;
try {
git = JGitUtils.openRepo(fileSet.getBasedir());
Status status = git.status().call();
List<ScmFile> changedFiles = getFileStati(status);
return new StatusScmResult("JGit status", changedFiles);
} catch (Exception e) {
throw new ScmException("JGit status failure!", e);
} finally {
JGitUtils.closeRepo(git);
}
}
Aggregations