Search in sources :

Example 1 with InfoItem

use of org.apache.maven.scm.command.info.InfoItem 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;
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) InfoItem(org.apache.maven.scm.command.info.InfoItem) ScmException(org.apache.maven.scm.ScmException) DefaultLog(org.apache.maven.scm.log.DefaultLog) InfoScmResult(org.apache.maven.scm.command.info.InfoScmResult) SvnInfoCommandExpanded(org.apache.maven.scm.provider.svn.svnexe.command.info.SvnInfoCommandExpanded)

Aggregations

ScmException (org.apache.maven.scm.ScmException)1 ScmFileSet (org.apache.maven.scm.ScmFileSet)1 InfoItem (org.apache.maven.scm.command.info.InfoItem)1 InfoScmResult (org.apache.maven.scm.command.info.InfoScmResult)1 DefaultLog (org.apache.maven.scm.log.DefaultLog)1 SvnInfoCommandExpanded (org.apache.maven.scm.provider.svn.svnexe.command.info.SvnInfoCommandExpanded)1