Search in sources :

Example 21 with ScmBranch

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

the class SvnChangeLogCommandTest method testCommandLineWithBranchBothDates.

public void testCommandLineWithBranchBothDates() throws Exception {
    Date startDate = getDate(2003, Calendar.SEPTEMBER, 10, GMT_TIME_ZONE);
    Date endDate = getDate(2003, Calendar.OCTOBER, 10, GMT_TIME_ZONE);
    testCommandLine("scm:svn:http://foo.com/svn/trunk", new ScmBranch("my-test-branch"), startDate, endDate, "svn --non-interactive log -v -r \"{2003-09-10 00:00:00 +0000}:{2003-10-10 00:00:00 +0000}\" http://foo.com/svn/branches/my-test-branch http://foo.com/svn/trunk");
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) Date(java.util.Date)

Example 22 with ScmBranch

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

the class SvnChangeLogCommandTest method testCommandLineWithBranchEndDateOnly.

public void testCommandLineWithBranchEndDateOnly() throws Exception {
    Date endDate = getDate(2003, Calendar.OCTOBER, 10, 1, 1, 1, GMT_TIME_ZONE);
    // Only specifying end date should print no dates at all
    testCommandLine("scm:svn:http://foo.com/svn/trunk", new ScmBranch("my-test-branch"), null, endDate, "svn --non-interactive log -v http://foo.com/svn/branches/my-test-branch http://foo.com/svn/trunk");
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) Date(java.util.Date)

Example 23 with ScmBranch

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

the class GitUpdateCommand method createCommandLine.

/**
 * create the command line for updating the current branch with the info from the foreign repository.
 */
public static Commandline createCommandLine(GitScmProviderRepository repository, File workingDirectory, ScmVersion scmVersion) {
    Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "pull");
    cl.createArg().setLine(repository.getFetchUrl());
    // now set the branch where we would like to pull from
    if (scmVersion instanceof ScmBranch) {
        cl.createArg().setLine(scmVersion.getName());
    }
    return cl;
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) Commandline(org.codehaus.plexus.util.cli.Commandline)

Example 24 with ScmBranch

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

the class GitUpdateCommand method createLatestRevisionCommandLine.

/**
 * @param scmVersion a valid branch or <code>null</code> if the master branch should be taken
 * @return CommandLine for getting the latest commit on the given branch
 */
public static Commandline createLatestRevisionCommandLine(GitScmProviderRepository repository, File workingDirectory, ScmVersion scmVersion) {
    Commandline cl = GitCommandLineUtils.getBaseGitCommandLine(workingDirectory, "log");
    // only show exactly 1 commit
    cl.createArg().setValue("-n1");
    // same as --topo-order, but ensure ordering of merges
    cl.createArg().setValue("--date-order");
    if (scmVersion != null && scmVersion instanceof ScmBranch && scmVersion.getName() != null && scmVersion.getName().length() > 0) {
        // if any branch is given, lets take em
        cl.createArg().setValue(scmVersion.getName());
    }
    return cl;
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) Commandline(org.codehaus.plexus.util.cli.Commandline)

Example 25 with ScmBranch

use of org.apache.maven.scm.ScmBranch in project maven-plugins by apache.

the class AbstractScmPublishMojo method checkoutExisting.

protected void checkoutExisting() throws MojoExecutionException {
    if (scmProvider instanceof AbstractSvnScmProvider) {
        checkCreateRemoteSvnPath();
    }
    logInfo(MessageUtils.buffer().strong("%s") + " the pub tree from " + MessageUtils.buffer().strong("%s") + " into %s", (tryUpdate ? "Updating" : "Checking out"), pubScmUrl, checkoutDirectory);
    if (checkoutDirectory.exists() && !tryUpdate) {
        try {
            FileUtils.deleteDirectory(checkoutDirectory);
        } catch (IOException e) {
            logError(e.getMessage());
            throw new MojoExecutionException("Unable to remove old checkout directory: " + e.getMessage(), e);
        }
    }
    boolean forceCheckout = false;
    if (!checkoutDirectory.exists()) {
        if (tryUpdate) {
            logInfo("TryUpdate is configured but no local copy currently available: forcing checkout.");
        }
        checkoutDirectory.mkdirs();
        forceCheckout = true;
    }
    try {
        ScmFileSet fileSet = new ScmFileSet(checkoutDirectory, includes, excludes);
        ScmBranch branch = (scmBranch == null) ? null : new ScmBranch(scmBranch);
        ScmResult scmResult = null;
        if (tryUpdate && !forceCheckout) {
            scmResult = scmProvider.update(scmRepository, fileSet, branch);
        } else {
            int attempt = 0;
            while (scmResult == null) {
                try {
                    scmResult = scmProvider.checkOut(scmRepository, fileSet, branch);
                } catch (ScmException e) {
                    // give it max 2 times to retry
                    if (attempt++ < 2) {
                        try {
                            // wait 3 seconds
                            Thread.sleep(3 * 1000);
                        } catch (InterruptedException ie) {
                        // noop
                        }
                    } else {
                        throw e;
                    }
                }
            }
        }
        checkScmResult(scmResult, "check out from SCM");
    } catch (ScmException e) {
        logError(e.getMessage());
        throw new MojoExecutionException("An error occurred during the checkout process: " + e.getMessage(), e);
    } catch (IOException e) {
        logError(e.getMessage());
        throw new MojoExecutionException("An error occurred during the checkout process: " + e.getMessage(), e);
    }
}
Also used : ScmBranch(org.apache.maven.scm.ScmBranch) ScmFileSet(org.apache.maven.scm.ScmFileSet) ScmException(org.apache.maven.scm.ScmException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) ScmResult(org.apache.maven.scm.ScmResult) AbstractSvnScmProvider(org.apache.maven.scm.provider.svn.AbstractSvnScmProvider) IOException(java.io.IOException)

Aggregations

ScmBranch (org.apache.maven.scm.ScmBranch)25 Date (java.util.Date)9 ScmException (org.apache.maven.scm.ScmException)9 ScmFileSet (org.apache.maven.scm.ScmFileSet)7 Commandline (org.codehaus.plexus.util.cli.Commandline)7 ScmTag (org.apache.maven.scm.ScmTag)5 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)5 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 ScmVersion (org.apache.maven.scm.ScmVersion)4 ScmProvider (org.apache.maven.scm.provider.ScmProvider)4 File (java.io.File)3 ChangeSet (org.apache.maven.scm.ChangeSet)3 ScmRevision (org.apache.maven.scm.ScmRevision)3 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)3 SvnScmProviderRepository (org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository)3 ScmRepository (org.apache.maven.scm.repository.ScmRepository)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)2