public void setUp() throws Exception {
workdir = testUtils.createTempDir("Repository1");
workdir2 = testUtils.createTempDir("Repository2");
repository1 = new TestRepository(new File(workdir, Constants.DOT_GIT));
// now we create a project in repo1
IProject project = testUtils.createProjectInLocalFileSystem(workdir,
projectName);
testUtils.addFileToProject(project, "folder1/file1.txt", "Hello world");
repository1.connect(project);
repository1.trackAllFiles(project);
repository1.commit("Initial commit");
// let's get rid of the project
project.delete(false, false, null);
// let's clone repository1 to repository2
URIish uri = new URIish("file:///"
+ repository1.getRepository().getDirectory().toString());
CloneOperation clop = new CloneOperation(uri, true, null, workdir2,
"refs/heads/master", "origin", 0);
clop.run(null);
Repository existingRepo = Activator
.getDefault()
.getRepositoryCache()
.lookupRepository(
new File(workdir2, Constants.DOT_GIT));
repository2 = new TestRepository(existingRepo);
// we push to branch "test" of repository2
RefUpdate createBranch = repository2.getRepository().updateRef(
"refs/heads/test");
createBranch.setNewObjectId(repository2.getRepository().resolve(
"refs/heads/master"));