Search in sources :

Example 6 with CloneOperation

use of org.eclipse.egit.core.op.CloneOperation in project egit by eclipse.

the class SelectionForViewsTest method before.

@Before
public void before() throws Exception {
    localRepositoryDir = createProjectAndCommitToRepository();
    remoteRepositoryDir = createRemoteRepository(localRepositoryDir);
    URIish uri = new URIish("file:///" + remoteRepositoryDir.getPath());
    File workdir = new File(getTestDirectory(), "ClonedRepo");
    CloneOperation op = new CloneOperation(uri, true, null, workdir, "refs/heads/master", "origin", 0);
    op.run(null);
    clonedRepositoryDir = new File(workdir, Constants.DOT_GIT);
    RepositoryUtil repoUtil = Activator.getDefault().getRepositoryUtil();
    repoUtil.addConfiguredRepository(localRepositoryDir);
    repoUtil.addConfiguredRepository(clonedRepositoryDir);
    // it's bare
    repoUtil.addConfiguredRepository(remoteRepositoryDir);
    stagingView = TestUtil.showView(StagingView.VIEW_ID);
    reflogView = TestUtil.showView(ReflogView.VIEW_ID);
    rebaseInteractiveView = TestUtil.showView(RebaseInteractiveView.VIEW_ID);
    repoView = TestUtil.showView(RepositoriesView.VIEW_ID);
    RepositoriesView repos = (RepositoriesView) repoView.getViewReference().getView(false);
    repos.setReactOnSelection(true);
    historyView = TestUtil.showHistoryView();
    IHistoryView history = (IHistoryView) historyView.getViewReference().getView(false);
    ((GenericHistoryView) history).setLinkingEnabled(true);
    // Ensure that the git history page is active
    Exception[] exception = { null };
    PlatformUI.getWorkbench().getDisplay().syncExec(() -> {
        try {
            history.showHistoryFor(new RepositoryNode(null, lookupRepository(localRepositoryDir)), true);
        } catch (Exception e) {
            exception[0] = e;
        }
    });
    if (exception[0] != null) {
        throw exception[0];
    }
    waitForRefreshes();
}
Also used : URIish(org.eclipse.jgit.transport.URIish) GenericHistoryView(org.eclipse.team.internal.ui.history.GenericHistoryView) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) RepositoryNode(org.eclipse.egit.ui.internal.repository.tree.RepositoryNode) File(java.io.File) IHistoryView(org.eclipse.team.ui.history.IHistoryView) CloneOperation(org.eclipse.egit.core.op.CloneOperation) RepositoryUtil(org.eclipse.egit.core.RepositoryUtil) Before(org.junit.Before)

Example 7 with CloneOperation

use of org.eclipse.egit.core.op.CloneOperation in project jbosstools-openshift by jbosstools.

the class TestRepository method cloneRepository.

public TestRepository cloneRepository(File path) throws URISyntaxException, InvocationTargetException, InterruptedException, IOException {
    URIish uri = new URIish("file:///" + repository.getDirectory().toString());
    CloneOperation clop = new CloneOperation(uri, true, null, path, Constants.R_HEADS + Constants.MASTER, Constants.DEFAULT_REMOTE_NAME, 0);
    clop.run(null);
    RepositoryCache repositoryCache = Activator.getDefault().getRepositoryCache();
    Repository clonedRepository = repositoryCache.lookupRepository(new File(path, Constants.DOT_GIT));
    return new TestRepository(clonedRepository);
}
Also used : URIish(org.eclipse.jgit.transport.URIish) Repository(org.eclipse.jgit.lib.Repository) RepositoryCache(org.eclipse.egit.core.RepositoryCache) IFile(org.eclipse.core.resources.IFile) File(java.io.File) CloneOperation(org.eclipse.egit.core.op.CloneOperation)

Example 8 with CloneOperation

use of org.eclipse.egit.core.op.CloneOperation in project jbosstools-openshift by jbosstools.

the class EGitUtils method cloneRepository.

public static void cloneRepository(String uri, String remoteName, String ref, File destination, PostCloneTask postCloneTask, IProgressMonitor monitor) throws URISyntaxException, InvocationTargetException, InterruptedException {
    URIish gitUri = new URIish(uri);
    if (StringUtils.isEmptyOrNull(ref)) {
        ref = Constants.HEAD;
    }
    CloneOperation cloneOperation = new CloneOperation(gitUri, true, null, destination, ref, remoteName, getEgitTimeout());
    if (postCloneTask != null) {
        cloneOperation.addPostCloneTask(postCloneTask);
    }
    cloneOperation.run(monitor);
}
Also used : URIish(org.eclipse.jgit.transport.URIish) CloneOperation(org.eclipse.egit.core.op.CloneOperation)

Example 9 with CloneOperation

use of org.eclipse.egit.core.op.CloneOperation in project egit by eclipse.

the class PushTest method setup.

@Before
public void setup() throws Exception {
    TestUtil.disableProxy();
    remoteRepository = new SampleTestRepository(NUMBER_RANDOM_COMMITS, true);
    localRepoPath = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile(), "test" + System.nanoTime());
    String branch = Constants.R_HEADS + SampleTestRepository.FIX;
    CloneOperation cloneOperation = new CloneOperation(new URIish(remoteRepository.getUri()), true, null, localRepoPath, branch, "origin", 30);
    cloneOperation.setCredentialsProvider(new UsernamePasswordCredentialsProvider("agitter", "letmein"));
    cloneOperation.run(new NullProgressMonitor());
    file = new File(localRepoPath, SampleTestRepository.A_txt_name);
    assertTrue(file.exists());
    localRepository = Activator.getDefault().getRepositoryCache().lookupRepository(new File(localRepoPath, ".git"));
    assertNotNull(localRepository);
}
Also used : URIish(org.eclipse.jgit.transport.URIish) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) UsernamePasswordCredentialsProvider(org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider) SampleTestRepository(org.eclipse.egit.ui.wizards.clone.SampleTestRepository) File(java.io.File) CloneOperation(org.eclipse.egit.core.op.CloneOperation) Before(org.junit.Before)

Example 10 with CloneOperation

use of org.eclipse.egit.core.op.CloneOperation in project egit by eclipse.

the class LocalRepositoryTestCase method createChildRepository.

protected File createChildRepository(File repositoryDir) throws Exception {
    Repository myRepository = lookupRepository(repositoryDir);
    URIish uri = new URIish("file:///" + myRepository.getDirectory());
    File workdir = new File(testDirectory, CHILDREPO);
    CloneOperation clop = new CloneOperation(uri, true, null, workdir, "refs/heads/master", "origin", 0);
    clop.run(null);
    return new File(workdir, Constants.DOT_GIT);
}
Also used : URIish(org.eclipse.jgit.transport.URIish) Repository(org.eclipse.jgit.lib.Repository) IFile(org.eclipse.core.resources.IFile) File(java.io.File) CloneOperation(org.eclipse.egit.core.op.CloneOperation)

Aggregations

CloneOperation (org.eclipse.egit.core.op.CloneOperation)16 File (java.io.File)15 URIish (org.eclipse.jgit.transport.URIish)15 Repository (org.eclipse.jgit.lib.Repository)10 TestRepository (org.eclipse.egit.core.test.TestRepository)7 Before (org.junit.Before)7 IFile (org.eclipse.core.resources.IFile)3 IProject (org.eclipse.core.resources.IProject)3 Test (org.junit.Test)3 CoreException (org.eclipse.core.runtime.CoreException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 RepositoryUtil (org.eclipse.egit.core.RepositoryUtil)2 PostCloneTask (org.eclipse.egit.core.op.CloneOperation.PostCloneTask)2 RefUpdate (org.eclipse.jgit.lib.RefUpdate)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 LinkedList (java.util.LinkedList)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Status (org.eclipse.core.runtime.Status)1 ProjectReference (org.eclipse.egit.core.ProjectReference)1