use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.
the class IntegrityBranchCommand method executeBranchCommand.
/**
* {@inheritDoc}
*/
@Override
public BranchScmResult executeBranchCommand(ScmProviderRepository repository, ScmFileSet fileSet, String branchName, String message) throws ScmException {
BranchScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
Project siProject = iRepo.getProject();
getLogger().info("Attempting to branch project " + siProject.getProjectName() + " using branch name '" + branchName + "'");
try {
Project.validateTag(branchName);
Response res = siProject.createDevPath(branchName);
int exitCode = res.getExitCode();
boolean success = (exitCode == 0 ? true : false);
ScmResult scmResult = new ScmResult(res.getCommandString(), "", "Exit Code: " + exitCode, success);
result = new BranchScmResult(new ArrayList<ScmFile>(), scmResult);
} 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 BranchScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
} catch (Exception e) {
getLogger().error("Failed to checkpoint project! " + e.getMessage());
result = new BranchScmResult("si createdevpath", e.getMessage(), "", false);
}
return result;
}
use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.
the class BranchCommandTckTest method testBranchCommandTest.
public void testBranchCommandTest() throws Exception {
String branch = getBranch();
@SuppressWarnings("deprecation") BranchScmResult branchResult = getScmManager().getProviderByUrl(getScmUrl()).branch(getScmRepository(), new ScmFileSet(getWorkingCopy()), branch);
assertResultIsSuccess(branchResult);
// see https://issues.apache.org/jira/browse/SCM-754
// assertEquals( "check all 4 files branched", 4, branchResult.getBranchedFiles().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 ScmBranch(branch));
assertResultIsSuccess(checkoutResult);
assertEquals("check readme.txt contents is from branched version", "/readme.txt", FileUtils.fileRead(readmeTxt));
}
use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.
the class BranchMojo method execute.
/**
* {@inheritDoc}
*/
public void execute() throws MojoExecutionException {
super.execute();
try {
ScmRepository repository = getScmRepository();
ScmProvider provider = getScmManager().getProviderByRepository(repository);
String finalBranch = provider.sanitizeTagName(branch);
getLog().info("Final Branch Name: '" + finalBranch + "'");
ScmBranchParameters scmBranchParameters = new ScmBranchParameters(message);
scmBranchParameters.setRemoteBranching(remoteBranching);
BranchScmResult result = provider.branch(repository, getFileSet(), finalBranch, scmBranchParameters);
checkResult(result);
} catch (IOException e) {
throw new MojoExecutionException("Cannot run branch command : ", e);
} catch (ScmException e) {
throw new MojoExecutionException("Cannot run branch command : ", e);
}
}
use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.
the class TfsScmProvider method branch.
protected BranchScmResult branch(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
TfsBranchCommand command = new TfsBranchCommand();
command.setLogger(getLogger());
return (BranchScmResult) command.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.branch.BranchScmResult in project maven-scm by apache.
the class CvsJavaBranchCommand method executeCvsCommand.
/**
* {@inheritDoc}
*/
protected BranchScmResult executeCvsCommand(Commandline cl) throws ScmException {
CvsLogListener logListener = new CvsLogListener();
CvsBranchConsumer consumer = new CvsBranchConsumer(getLogger());
try {
boolean isSuccess = CvsConnection.processCommand(cl.getArguments(), cl.getWorkingDirectory().getAbsolutePath(), logListener, getLogger());
if (!isSuccess) {
return new BranchScmResult(cl.toString(), "The cvs branch 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) {
getLogger().error(e.getMessage(), e);
return new BranchScmResult(cl.toString(), "The cvs branch command failed.", logListener.getStderr().toString(), false);
}
return new BranchScmResult(cl.toString(), consumer.getTaggedFiles());
}
Aggregations