use of org.apache.maven.scm.command.tag.TagScmResult in project maven-scm by apache.
the class JazzScmProvider method tag.
/**
* {@inheritDoc}
*/
protected TagScmResult tag(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
getLogger().debug("JazzScmProvider:tag()");
// We need to call the status command first, so that we can get the details of the stream etc.
// This is needed for workspace deliveries and snapshot promotions.
JazzStatusCommand statusCommand = new JazzStatusCommand();
statusCommand.setLogger(getLogger());
statusCommand.execute(repository, fileSet, parameters);
JazzTagCommand command = new JazzTagCommand();
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 JazzTagCommand method executeTagCommand.
/**
* {@inheritDoc}
*/
protected ScmResult executeTagCommand(ScmProviderRepository repo, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters) throws ScmException {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Executing tag command...");
}
JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo;
getLogger().debug("Creating Snapshot...");
StreamConsumer tagConsumer = // No need for a dedicated consumer for this
new DebugLoggerConsumer(getLogger());
ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
JazzScmCommand tagCreateSnapshotCmd = createTagCreateSnapshotCommand(jazzRepo, fileSet, tag, scmTagParameters);
int status = tagCreateSnapshotCmd.execute(tagConsumer, errConsumer);
if (status != 0) {
return new TagScmResult(tagCreateSnapshotCmd.getCommandString(), "Error code for Jazz SCM tag (SNAPSHOT) command - " + status, errConsumer.getOutput(), false);
}
// ------------------------------------------------------------------
// We create the workspace based on the tag here, as the scm tool
// can not currently check directly out from a snapshot (only a workspace).
getLogger().debug("Creating Workspace from Snapshot...");
JazzScmCommand tagCreateWorkspaceCmd = createTagCreateWorkspaceCommand(jazzRepo, fileSet, tag);
errConsumer = new ErrorConsumer(getLogger());
status = tagCreateWorkspaceCmd.execute(tagConsumer, errConsumer);
if (status != 0) {
return new TagScmResult(tagCreateWorkspaceCmd.getCommandString(), "Error code for Jazz SCM tag (WORKSPACE) command - " + status, errConsumer.getOutput(), false);
}
if (jazzRepo.isPushChangesAndHaveFlowTargets()) {
// isPushChanges = true, and we have something to deliver and promote to.
getLogger().debug("Promoting and delivering...");
// So we deliver the code to the target stream (or workspace)
getLogger().debug("Delivering...");
JazzScmCommand tagDeliverCommand = createTagDeliverCommand(jazzRepo, fileSet, tag);
errConsumer = new ErrorConsumer(getLogger());
status = tagDeliverCommand.execute(tagConsumer, errConsumer);
if (status != 0) {
return new TagScmResult(tagDeliverCommand.getCommandString(), "Error code for Jazz SCM deliver command - " + status, errConsumer.getOutput(), false);
}
// And now we promote the snapshot to the target stream (or workspace)
getLogger().debug("Promoting snapshot...");
JazzScmCommand tagSnapshotPromoteCommand = createTagSnapshotPromoteCommand(jazzRepo, fileSet, tag);
errConsumer = new ErrorConsumer(getLogger());
status = tagSnapshotPromoteCommand.execute(tagConsumer, errConsumer);
if (status != 0) {
return new TagScmResult(tagSnapshotPromoteCommand.getCommandString(), "Error code for Jazz SCM snapshot promote command - " + status, errConsumer.getOutput(), false);
}
}
// We don't have a JazzTagConsumer so just build up all the files...
List<ScmFile> taggedFiles = new ArrayList<ScmFile>(fileSet.getFileList().size());
for (File f : fileSet.getFileList()) {
taggedFiles.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED));
}
// So we return tagSnapshotCmd and not tagWorkspaceCmd.
return new TagScmResult(tagCreateSnapshotCmd.getCommandString(), taggedFiles);
}
use of org.apache.maven.scm.command.tag.TagScmResult in project maven-scm by apache.
the class IntegrityScmProvider method tag.
/**
* Maps to si checkpoint
*/
@Override
protected TagScmResult tag(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
IntegrityTagCommand command = new IntegrityTagCommand();
command.setLogger(getLogger());
return (TagScmResult) command.execute(repository, fileSet, params);
}
use of org.apache.maven.scm.command.tag.TagScmResult in project maven-scm by apache.
the class TagCommandTckTest method testTagCommandTest.
public void testTagCommandTest() throws Exception {
String tag = getTagName();
@SuppressWarnings("deprecation") TagScmResult tagResult = getScmManager().getProviderByUrl(getScmUrl()).tag(getScmRepository(), new ScmFileSet(getWorkingCopy()), tag);
assertResultIsSuccess(tagResult);
// see https://issues.apache.org/jira/browse/SCM-754
// assertEquals( "check all 4 files tagged", 4, tagResult.getTaggedFiles().size() );
File readmeTxt = new File(getWorkingCopy(), "readme.txt");
assertEquals("check readme.txt contents", "/readme.txt", FileUtils.fileRead(readmeTxt));
this.edit(getWorkingCopy(), "readme.txt", null, getScmRepository());
changeReadmeTxt(readmeTxt);
CheckInScmResult checkinResult = getScmManager().checkIn(getScmRepository(), new ScmFileSet(getWorkingCopy()), "commit message");
assertResultIsSuccess(checkinResult);
CheckOutScmResult checkoutResult = getScmManager().checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy()));
assertResultIsSuccess(checkoutResult);
readmeTxt = new File(getAssertionCopy(), "readme.txt");
assertEquals("check readme.txt contents", "changed file", FileUtils.fileRead(readmeTxt));
deleteDirectory(getAssertionCopy());
assertFalse("check previous assertion copy deleted", getAssertionCopy().exists());
checkoutResult = getScmManager().getProviderByUrl(getScmUrl()).checkOut(getScmRepository(), new ScmFileSet(getAssertionCopy()), new ScmTag(tag));
assertResultIsSuccess(checkoutResult);
assertEquals("check readme.txt contents is from tagged version", "/readme.txt", FileUtils.fileRead(readmeTxt));
}
use of org.apache.maven.scm.command.tag.TagScmResult in project maven-scm by apache.
the class GitTagCommand method executeTagCommand.
/**
* {@inheritDoc}
*/
public ScmResult executeTagCommand(ScmProviderRepository repo, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters) throws ScmException {
if (tag == null || StringUtils.isEmpty(tag.trim())) {
throw new ScmException("tag name must be specified");
}
if (!fileSet.getFileList().isEmpty()) {
throw new ScmException("This provider doesn't support tagging subsets of a directory");
}
GitScmProviderRepository repository = (GitScmProviderRepository) repo;
File messageFile = FileUtils.createTempFile("maven-scm-", ".commit", null);
try {
FileUtils.fileWrite(messageFile.getAbsolutePath(), scmTagParameters.getMessage());
} catch (IOException ex) {
return new TagScmResult(null, "Error while making a temporary file for the commit message: " + ex.getMessage(), null, false);
}
try {
CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
int exitCode;
Commandline clTag = createCommandLine(repository, fileSet.getBasedir(), tag, messageFile);
exitCode = GitCommandLineUtils.execute(clTag, stdout, stderr, getLogger());
if (exitCode != 0) {
return new TagScmResult(clTag.toString(), "The git-tag command failed.", stderr.getOutput(), false);
}
if (repo.isPushChanges()) {
// and now push the tag to the configured upstream repository
Commandline clPush = createPushCommandLine(repository, fileSet, tag);
exitCode = GitCommandLineUtils.execute(clPush, stdout, stderr, getLogger());
if (exitCode != 0) {
return new TagScmResult(clPush.toString(), "The git-push command failed.", stderr.getOutput(), false);
}
}
// plus search for the tagged files
GitListConsumer listConsumer = new GitListConsumer(getLogger(), fileSet.getBasedir(), ScmFileStatus.TAGGED);
Commandline clList = GitListCommand.createCommandLine(repository, fileSet.getBasedir());
exitCode = GitCommandLineUtils.execute(clList, listConsumer, stderr, getLogger());
if (exitCode != 0) {
return new CheckOutScmResult(clList.toString(), "The git-ls-files command failed.", stderr.getOutput(), false);
}
return new TagScmResult(clTag.toString(), listConsumer.getListedFiles());
} finally {
try {
FileUtils.forceDelete(messageFile);
} catch (IOException ex) {
// ignore
}
}
}
Aggregations