use of org.apache.maven.scm.command.info.InfoScmResult in project maven-scm by apache.
the class GitInfoCommandTckTest method testInfoCommandWithZeroShortRevision.
public void testInfoCommandWithZeroShortRevision() throws Exception {
GitScmTestUtils.initRepo("src/test/resources/git/info", getRepositoryRoot(), getWorkingCopy());
ScmProvider provider = getScmManager().getProviderByUrl(getScmUrl());
ScmProviderRepository repository = provider.makeProviderScmRepository(getRepositoryRoot());
assertNotNull(repository);
CommandParameters commandParameters = new CommandParameters();
commandParameters.setInt(CommandParameter.SCM_SHORT_REVISION_LENGTH, 0);
InfoScmResult result = provider.info(repository, new ScmFileSet(getRepositoryRoot()), commandParameters);
assertNotNull(result);
assertTrue("revision should be not empty, minimum 4 (see git help rev-parse --short)", result.getInfoItems().get(0).getRevision().length() >= 4);
}
use of org.apache.maven.scm.command.info.InfoScmResult in project maven-plugins by apache.
the class ChangeLogReport method getRevisionForTag.
/**
* Resolves the given tag to the revision number.
*
* @param tag
* @param repository
* @param provider
* @return
* @throws ScmException
*/
private String getRevisionForTag(final String tag, final ScmRepository repository, final ScmProvider provider) throws ScmException {
if (repository.getProvider().equals("svn")) {
if (tag == null) {
return "HEAD";
}
SvnInfoCommandExpanded infoCommand = new SvnInfoCommandExpanded();
infoCommand.setLogger(new DefaultLog());
InfoScmResult infoScmResult = infoCommand.executeInfoTagCommand((SvnScmProviderRepository) repository.getProviderRepository(), new ScmFileSet(basedir), tag, null, false, null);
if (infoScmResult.getInfoItems().size() == 0) {
throw new ScmException("There is no tag named '" + tag + "' in the Subversion repository.");
}
InfoItem infoItem = infoScmResult.getInfoItems().get(0);
String revision = infoItem.getLastChangedRevision();
getLog().info(String.format("Resolved tag '%s' to revision '%s'", tag, revision));
return revision;
}
return tag;
}
use of org.apache.maven.scm.command.info.InfoScmResult in project maven-scm by apache.
the class HgScmProvider method info.
/**
* returns result of hg id -i
* @since 1.5
* @see org.apache.maven.scm.provider.AbstractScmProvider#info(org.apache.maven.scm.provider.ScmProviderRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters)
*/
@Override
public InfoScmResult info(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
HgInfoCommand infoCommand = new HgInfoCommand();
infoCommand.setLogger(getLogger());
return (InfoScmResult) infoCommand.execute(repository, fileSet, parameters);
}
use of org.apache.maven.scm.command.info.InfoScmResult in project maven-scm by apache.
the class HgInfoCommand method executeCommand.
@Override
protected ScmResult executeCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
String[] revCmd = new String[] { HgCommandConstants.REVNO_CMD, "-i" };
HgInfoConsumer consumer = new HgInfoConsumer(getLogger());
ScmResult scmResult = HgUtils.execute(consumer, getLogger(), fileSet.getBasedir(), revCmd);
return new InfoScmResult(consumer.getInfoItems(), scmResult);
}
use of org.apache.maven.scm.command.info.InfoScmResult in project maven-scm by apache.
the class SvnInfoCommand method executeInfoCommand.
public InfoScmResult executeInfoCommand(SvnScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters, boolean recursive, String revision) throws ScmException {
Commandline cl = createCommandLine(repository, fileSet, recursive, revision);
SvnInfoConsumer consumer = new SvnInfoConsumer();
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
if (getLogger().isInfoEnabled()) {
getLogger().info("Executing: " + SvnCommandLineUtils.cryptPassword(cl));
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
getLogger().info("Working directory: " + cl.getWorkingDirectory().getAbsolutePath());
}
}
int exitCode;
try {
exitCode = SvnCommandLineUtils.execute(cl, consumer, stderr, getLogger());
} catch (CommandLineException ex) {
throw new ScmException("Error while executing command.", ex);
}
if (exitCode != 0) {
return new InfoScmResult(cl.toString(), "The svn command failed.", stderr.getOutput(), false);
}
return new InfoScmResult(cl.toString(), consumer.getInfoItems());
}
Aggregations