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();
}
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);
}
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);
}
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);
}
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);
}
Aggregations