use of org.apache.maven.scm.command.tag.TagScmResult in project maven-scm by apache.
the class HgScmProvider method tag.
/**
* {@inheritDoc}
*/
public TagScmResult tag(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
HgTagCommand command = new HgTagCommand();
command.setLogger(getLogger());
return (TagScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.tag.TagScmResult in project maven-scm by apache.
the class ClearCaseTagCommand method executeTagCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeTagCommand(ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("executing tag command...");
}
Commandline cl = createCommandLine(fileSet, tag);
ClearCaseCheckInConsumer consumer = new ClearCaseCheckInConsumer(getLogger());
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
try {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Creating label: " + tag);
}
Commandline newLabelCommandLine = createNewLabelCommandLine(fileSet, tag);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing: " + newLabelCommandLine.getWorkingDirectory().getAbsolutePath() + ">>" + newLabelCommandLine.toString());
}
exitCode = CommandLineUtils.executeCommandLine(newLabelCommandLine, new CommandLineUtils.StringStreamConsumer(), stderr);
if (exitCode == 0) {
getLogger().debug("Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString());
exitCode = CommandLineUtils.executeCommandLine(cl, consumer, stderr);
}
} catch (CommandLineException ex) {
throw new ScmException("Error while executing clearcase command.", ex);
}
if (exitCode != 0) {
return new TagScmResult(cl.toString(), "The cleartool command failed.", stderr.getOutput(), false);
}
return new TagScmResult(cl.toString(), consumer.getCheckedInFiles());
}
use of org.apache.maven.scm.command.tag.TagScmResult in project maven-scm by apache.
the class HgTagCommand method executeTagCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeTagCommand(ScmProviderRepository scmProviderRepository, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters) throws ScmException {
if (tag == null || StringUtils.isEmpty(tag.trim())) {
throw new ScmException("tag must be specified");
}
if (!fileSet.getFileList().isEmpty()) {
throw new ScmException("This provider doesn't support tagging subsets of a directory : " + fileSet.getFileList());
}
File workingDir = fileSet.getBasedir();
// build the command
String[] tagCmd = new String[] { HgCommandConstants.TAG_CMD, HgCommandConstants.MESSAGE_OPTION, scmTagParameters.getMessage(), tag };
// keep the command about in string form for reporting
StringBuilder cmd = joinCmd(tagCmd);
HgTagConsumer consumer = new HgTagConsumer(getLogger());
ScmResult result = HgUtils.execute(consumer, getLogger(), workingDir, tagCmd);
HgScmProviderRepository repository = (HgScmProviderRepository) scmProviderRepository;
if (result.isSuccess()) {
if (repository.isPushChanges()) {
if (!repository.getURI().equals(fileSet.getBasedir().getAbsolutePath())) {
String branchName = HgUtils.getCurrentBranchName(getLogger(), workingDir);
boolean differentOutgoingBranch = HgUtils.differentOutgoingBranchFound(getLogger(), workingDir, branchName);
String[] pushCmd = new String[] { HgCommandConstants.PUSH_CMD, differentOutgoingBranch ? HgCommandConstants.REVISION_OPTION + branchName : null, repository.getURI() };
result = HgUtils.execute(new HgConsumer(getLogger()), getLogger(), fileSet.getBasedir(), pushCmd);
}
}
} else {
throw new ScmException("Error while executing command " + cmd.toString());
}
// do an inventory to return the files tagged (all of them)
String[] listCmd = new String[] { HgCommandConstants.INVENTORY_CMD };
HgListConsumer listconsumer = new HgListConsumer(getLogger());
result = HgUtils.execute(listconsumer, getLogger(), fileSet.getBasedir(), listCmd);
if (result.isSuccess()) {
List<ScmFile> files = listconsumer.getFiles();
List<ScmFile> fileList = new ArrayList<ScmFile>();
for (ScmFile f : files) {
if (!f.getPath().endsWith(".hgtags")) {
fileList.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED));
}
}
return new TagScmResult(fileList, result);
} else {
throw new ScmException("Error while executing command " + cmd.toString());
}
}
use of org.apache.maven.scm.command.tag.TagScmResult in project maven-scm by apache.
the class CvsJavaTagCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected TagScmResult executeCvsCommand(Commandline cl) throws ScmException {
CvsLogListener logListener = new CvsLogListener();
CvsTagConsumer consumer = new CvsTagConsumer(getLogger());
try {
boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
if (!isSuccess) {
return new TagScmResult(cl.toString(), "The cvs tag command failed.", logListener.getStderr().toString(), false);
}
BufferedReader stream = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(logListener.getStdout().toString().getBytes())));
String line;
while ((line = stream.readLine()) != null) {
consumer.consumeLine(line);
}
} catch (Exception e) {
e.printStackTrace();
return new TagScmResult(cl.toString(), "The cvs tag command failed.", logListener.getStderr().toString(), false);
}
return new TagScmResult(cl.toString(), consumer.getTaggedFiles());
}
use of org.apache.maven.scm.command.tag.TagScmResult in project maven-scm by apache.
the class IntegrityTagCommand method executeTagCommand.
/**
* {@inheritDoc}
*/
@Override
public TagScmResult executeTagCommand(ScmProviderRepository repository, ScmFileSet fileSet, String tagName, ScmTagParameters scmTagParameters) throws ScmException {
getLogger().info("Attempting to checkpoint project associated with sandbox " + fileSet.getBasedir().getAbsolutePath());
TagScmResult result;
String message = scmTagParameters.getMessage();
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
try {
// First validate the checkpoint label string by evaluating the groovy script
String chkptLabel = evalGroovyExpression(tagName);
Project.validateTag(chkptLabel);
String msg = ((null == message || message.length() == 0) ? System.getProperty("message") : message);
// Get information about the Project
Project siProject = iRepo.getProject();
// Ensure this is not a build project configuration
if (!siProject.isBuild()) {
Response res = siProject.checkpoint(msg, chkptLabel);
int exitCode = res.getExitCode();
boolean success = (exitCode == 0 ? true : false);
WorkItem wi = res.getWorkItem(siProject.getConfigurationPath());
String chkpt = wi.getResult().getField("resultant").getItem().getId();
getLogger().info("Successfully checkpointed project " + siProject.getConfigurationPath() + " with label '" + chkptLabel + "', new revision is " + chkpt);
result = new TagScmResult(res.getCommandString(), wi.getResult().getMessage(), "Exit Code: " + exitCode, success);
} else {
getLogger().error("Cannot checkpoint a build project configuration: " + siProject.getConfigurationPath() + "!");
result = new TagScmResult("si checkpoint", "Cannot checkpoint a build project configuration!", "", false);
}
} catch (CompilationFailedException cfe) {
getLogger().error("Groovy Compilation Exception: " + cfe.getMessage());
result = new TagScmResult("si checkpoint", cfe.getMessage(), "", false);
} catch (APIException aex) {
ExceptionHandler eh = new ExceptionHandler(aex);
getLogger().error("MKS API Exception: " + eh.getMessage());
getLogger().info(eh.getCommand() + " exited with return code " + eh.getExitCode());
result = new TagScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
} catch (Exception e) {
getLogger().error("Failed to checkpoint project! " + e.getMessage());
result = new TagScmResult("si checkpoint", e.getMessage(), "", false);
}
return result;
}
Aggregations