use of org.apache.maven.scm.ScmBranch 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.ScmBranch in project maven-scm by apache.
the class GitCheckOutCommand method createCloneCommand.
/**
* create a git-clone repository command
*/
private Commandline createCloneCommand(GitScmProviderRepository repository, File workingDirectory, ScmVersion version, boolean shallow) {
Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory.getParentFile(), "clone");
if (shallow) {
cl.createArg().setValue("--depth");
cl.createArg().setValue("1");
}
if (version != null && (version instanceof ScmBranch)) {
cl.createArg().setValue("--branch");
cl.createArg().setValue(version.getName());
}
cl.createArg().setValue(repository.getFetchUrl());
cl.createArg().setFile(workingDirectory);
return cl;
}
use of org.apache.maven.scm.ScmBranch in project maven-scm by apache.
the class StarteamDiffCommandTest method testGetCommandLineWithLabels.
public void testGetCommandLineWithLabels() throws Exception {
ScmFileSet fileSet = new ScmFileSet(getWorkingCopy());
String workingCopy = StarteamCommandLineUtils.toJavaPath(getWorkingCopy().getPath());
String starteamUrl = "user:password@host:1234/project/view";
String mavenUrl = "scm:starteam:" + starteamUrl;
String expectedCmd = "stcmd diff -x -nologo -stop" + " -p " + starteamUrl + " -fp " + workingCopy + " -is -filter M" + " -vl label1 -vl label2 -eol on";
testCommandLine(mavenUrl, fileSet, new ScmBranch("label1"), new ScmBranch("label2"), expectedCmd);
}
use of org.apache.maven.scm.ScmBranch in project maven-plugins by apache.
the class ChangeLogReport method generateChangeSetsFromSCM.
/**
* creates a ChangeLog object and then connects to the SCM to generate the changed sets
*
* @return changedlogsets generated from the SCM
* @throws MavenReportException
*/
protected List<ChangeLogSet> generateChangeSetsFromSCM() throws MavenReportException {
try {
List<ChangeLogSet> changeSets = new ArrayList<ChangeLogSet>();
ScmRepository repository = getScmRepository();
ScmProvider provider = manager.getProviderByRepository(repository);
ChangeLogScmResult result;
if ("range".equals(type)) {
result = provider.changeLog(repository, new ScmFileSet(basedir), null, null, range, (ScmBranch) null, dateFormat);
checkResult(result);
changeSets.add(result.getChangeLog());
} else if ("tag".equals(type)) {
Iterator<String> tagsIter = tags.iterator();
String startTag = tagsIter.next();
String endTag = null;
if (tagsIter.hasNext()) {
while (tagsIter.hasNext()) {
endTag = tagsIter.next();
String endRevision = getRevisionForTag(endTag, repository, provider);
String startRevision = getRevisionForTag(startTag, repository, provider);
result = provider.changeLog(repository, new ScmFileSet(basedir), new ScmRevision(startRevision), new ScmRevision(endRevision));
checkResult(result);
result.getChangeLog().setStartVersion(new ScmRevision(startTag));
result.getChangeLog().setEndVersion(new ScmRevision(endTag));
changeSets.add(result.getChangeLog());
startTag = endTag;
}
} else {
String startRevision = getRevisionForTag(startTag, repository, provider);
String endRevision = getRevisionForTag(endTag, repository, provider);
result = provider.changeLog(repository, new ScmFileSet(basedir), new ScmRevision(startRevision), new ScmRevision(endRevision));
checkResult(result);
result.getChangeLog().setStartVersion(new ScmRevision(startTag));
result.getChangeLog().setEndVersion(null);
changeSets.add(result.getChangeLog());
}
} else if ("date".equals(type)) {
Iterator<String> dateIter = dates.iterator();
String startDate = dateIter.next();
String endDate = null;
if (dateIter.hasNext()) {
while (dateIter.hasNext()) {
endDate = dateIter.next();
result = provider.changeLog(repository, new ScmFileSet(basedir), parseDate(startDate), parseDate(endDate), 0, (ScmBranch) null);
checkResult(result);
changeSets.add(result.getChangeLog());
startDate = endDate;
}
} else {
result = provider.changeLog(repository, new ScmFileSet(basedir), parseDate(startDate), parseDate(endDate), 0, (ScmBranch) null);
checkResult(result);
changeSets.add(result.getChangeLog());
}
} else {
throw new MavenReportException("The type '" + type + "' isn't supported.");
}
filter(changeSets);
return changeSets;
} catch (ScmException e) {
throw new MavenReportException("Cannot run changelog command : ", e);
} catch (MojoExecutionException e) {
throw new MavenReportException("An error has occurred during changelog command : ", e);
}
}
use of org.apache.maven.scm.ScmBranch in project maven-plugins by apache.
the class AbstractScmPublishMojo method checkinFiles.
/**
* Check-in content from scm checkout.
*
* @throws MojoExecutionException
*/
protected void checkinFiles() throws MojoExecutionException {
if (skipCheckin) {
return;
}
ScmFileSet updatedFileSet = new ScmFileSet(checkoutDirectory);
try {
long start = System.currentTimeMillis();
CheckInScmResult checkinResult = checkScmResult(scmProvider.checkIn(scmRepository, updatedFileSet, new ScmBranch(scmBranch), checkinComment), "check-in files to SCM");
logInfo("Checked in %d file(s) to revision %s in %s", checkinResult.getCheckedInFiles().size(), checkinResult.getScmRevision(), DurationFormatUtils.formatPeriod(start, System.currentTimeMillis(), "H' h 'm' m 's' s'"));
} catch (ScmException e) {
throw new MojoExecutionException("Failed to perform SCM checkin", e);
}
}
Aggregations