use of org.apache.maven.scm.command.checkout.CheckOutScmResult 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.checkout.CheckOutScmResult in project maven-scm by apache.
the class GitCheckInCommandNoBranchTest method checkoutRepo.
protected CheckOutScmResult checkoutRepo(ScmRepository scmRepository) throws Exception {
FileUtils.deleteDirectory(workingDirectory);
CheckOutScmResult result = getScmManager().checkOut(scmRepository, new ScmFileSet(workingDirectory), (ScmVersion) null);
assertResultIsSuccess(result);
return result;
}
use of org.apache.maven.scm.command.checkout.CheckOutScmResult 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
}
}
}
use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.
the class GitExeCheckOutCommandNoBranchTest method testCheckoutNoBranch.
public void testCheckoutNoBranch() throws Exception {
if (!ScmTestCase.isSystemCmd("git")) {
System.out.println("skip test which git native executable in path");
return;
}
CheckOutScmResult result = checkoutRepo();
assertEquals(0, result.getCheckedOutFiles().size());
}
use of org.apache.maven.scm.command.checkout.CheckOutScmResult in project maven-scm by apache.
the class GitExeCheckOutCommandNoBranchTest method testDoubleCheckoutNoBranch.
public void testDoubleCheckoutNoBranch() throws Exception {
if (!ScmTestCase.isSystemCmd("git")) {
System.out.println("skip test which git native executable in path");
return;
}
CheckOutScmResult result = checkoutRepo();
assertEquals(0, result.getCheckedOutFiles().size());
CheckOutScmResult result2 = checkoutRepo();
assertEquals(0, result2.getCheckedOutFiles().size());
}
Aggregations