Search in sources :

Example 6 with ScmRevision

use of org.apache.maven.scm.ScmRevision in project maven-scm by apache.

the class MavenScmCli method main.

// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------
public static void main(String[] args) {
    MavenScmCli cli;
    try {
        cli = new MavenScmCli();
    } catch (Exception ex) {
        System.err.println("Error while starting Maven Scm.");
        ex.printStackTrace(System.err);
        return;
    }
    String scmUrl;
    String command;
    if (args.length != 3) {
        System.err.println("Usage: maven-scm-client <command> <working directory> <scm url> [<scmVersion> [<scmVersionType>]]");
        System.err.println("scmVersion is a branch name/tag name/revision number.");
        System.err.println("scmVersionType can be 'branch', 'tag', 'revision'. " + "The default value is 'revision'.");
        return;
    }
    command = args[0];
    // SCM-641
    File workingDirectory = new File(args[1]).getAbsoluteFile();
    scmUrl = args[2];
    ScmVersion scmVersion = null;
    if (args.length > 3) {
        String version = args[3];
        if (args.length > 4) {
            String type = args[4];
            if ("tag".equals(type)) {
                scmVersion = new ScmTag(version);
            } else if ("branch".equals(type)) {
                scmVersion = new ScmBranch(version);
            } else if ("revision".equals(type)) {
                scmVersion = new ScmRevision(version);
            } else {
                throw new IllegalArgumentException("'" + type + "' version type isn't known.");
            }
        } else {
            scmVersion = new ScmRevision(args[3]);
        }
    }
    cli.execute(scmUrl, command, workingDirectory, scmVersion);
    cli.stop();
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) ScmTag(org.apache.maven.scm.ScmTag) ScmRevision(org.apache.maven.scm.ScmRevision) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmRepositoryException(org.apache.maven.scm.repository.ScmRepositoryException) ScmException(org.apache.maven.scm.ScmException) NoSuchScmProviderException(org.apache.maven.scm.manager.NoSuchScmProviderException) ScmVersion(org.apache.maven.scm.ScmVersion)

Example 7 with ScmRevision

use of org.apache.maven.scm.ScmRevision in project maven-scm by apache.

the class SvnListCommandTest method testCommandLine.

private void testCommandLine(String scmUrl, boolean recursive, String revision, String commandLine) throws Exception {
    ScmFileSet fileSet = new ScmFileSet(new File("."), new File("."));
    Commandline cl = SvnListCommand.createCommandLine(getSvnRepository(scmUrl), fileSet, recursive, new ScmRevision(revision));
    assertCommandLine(commandLine + " http://foo.com/svn/trunk/.", new File(System.getProperty("java.io.tmpdir")), cl);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) Commandline(org.codehaus.plexus.util.cli.Commandline) ScmRevision(org.apache.maven.scm.ScmRevision) File(java.io.File)

Example 8 with ScmRevision

use of org.apache.maven.scm.ScmRevision in project maven-scm by apache.

the class GitCheckOutCommandTest method testCommandLine.

// ----------------------------------------------------------------------
// 
// ----------------------------------------------------------------------
private void testCommandLine(ScmManager scmManager, String scmUrl, String revision, String commandLine) throws Exception {
    ScmRepository repository = scmManager.makeScmRepository(scmUrl);
    GitScmProviderRepository gitRepository = (GitScmProviderRepository) repository.getProviderRepository();
    Commandline cl = GitCheckOutCommand.createCommandLine(gitRepository, workingDirectory, new ScmRevision(revision));
    assertCommandLine(commandLine, workingDirectory, cl);
}
Also used : ScmRepository(org.apache.maven.scm.repository.ScmRepository) GitScmProviderRepository(org.apache.maven.scm.provider.git.repository.GitScmProviderRepository) Commandline(org.codehaus.plexus.util.cli.Commandline) ScmRevision(org.apache.maven.scm.ScmRevision)

Example 9 with ScmRevision

use of org.apache.maven.scm.ScmRevision in project maven-scm by apache.

the class StarteamCheckInCommandTest method testGetCommandLineWithFileInSubDir.

public void testGetCommandLineWithFileInSubDir() throws Exception {
    ScmFileSet fileSet = new ScmFileSet(getWorkingCopy(), new File("src/test.txt"));
    String workingCopy = StarteamCommandLineUtils.toJavaPath(getWorkingCopy().getPath());
    String starteamUrl = "user:password@host:1234/project/view";
    String mavenUrl = "scm:starteam:" + starteamUrl;
    String expectedCmd = "stcmd ci -x -nologo -stop" + " -p " + starteamUrl + "/src" + " -fp " + workingCopy + "/src" + " -eol on test.txt";
    testCommandLine(mavenUrl, fileSet, "", new ScmRevision(""), "", "", expectedCmd);
}
Also used : ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmRevision(org.apache.maven.scm.ScmRevision) File(java.io.File)

Example 10 with ScmRevision

use of org.apache.maven.scm.ScmRevision 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);
    }
}
Also used : ScmProvider(org.apache.maven.scm.provider.ScmProvider) ScmBranch(org.apache.maven.scm.ScmBranch) ScmRepository(org.apache.maven.scm.repository.ScmRepository) ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmException(org.apache.maven.scm.ScmException) ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ScmRevision(org.apache.maven.scm.ScmRevision) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) MavenReportException(org.apache.maven.reporting.MavenReportException)

Aggregations

ScmRevision (org.apache.maven.scm.ScmRevision)28 File (java.io.File)12 ScmFileSet (org.apache.maven.scm.ScmFileSet)12 Commandline (org.codehaus.plexus.util.cli.Commandline)10 Date (java.util.Date)5 CommandParameters (org.apache.maven.scm.CommandParameters)5 AbstractAccuRevCommandTest (org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest)5 Test (org.junit.Test)5 ChangeFile (org.apache.maven.scm.ChangeFile)4 ScmException (org.apache.maven.scm.ScmException)4 ScmFile (org.apache.maven.scm.ScmFile)4 ScmVersion (org.apache.maven.scm.ScmVersion)4 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)4 ScmRepository (org.apache.maven.scm.repository.ScmRepository)4 ChangeFileMatcher.changeFile (org.apache.maven.scm.ChangeFileMatcher.changeFile)3 ScmBranch (org.apache.maven.scm.ScmBranch)3 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)3 FileDifference (org.apache.maven.scm.provider.accurev.FileDifference)3 Stream (org.apache.maven.scm.provider.accurev.Stream)3 Transaction (org.apache.maven.scm.provider.accurev.Transaction)3