use of org.eclipse.egit.core.test.TestRepository in project egit by eclipse.
the class AddOperationTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
gitDir = new File(project.getProject().getLocationURI().getPath(), Constants.DOT_GIT);
testRepository = new TestRepository(gitDir);
testRepository.connect(project.getProject());
}
use of org.eclipse.egit.core.test.TestRepository in project egit by eclipse.
the class BranchOperationTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
testRepository = new TestRepository(gitDir);
repository = testRepository.getRepository();
}
use of org.eclipse.egit.core.test.TestRepository in project egit by eclipse.
the class DeletePathsOperationTest method setUp.
@Before
public void setUp() throws Exception {
workdir = testUtils.createTempDir("Repository1");
repository1 = new TestRepository(new File(workdir, Constants.DOT_GIT));
project = testUtils.createProjectInLocalFileSystem(workdir, projectName);
repository1.connect(project);
}
use of org.eclipse.egit.core.test.TestRepository in project egit by eclipse.
the class DiscardChangesOperationTest method setUp.
@Before
public void setUp() throws Exception {
workdir = testUtils.createTempDir("Repository1");
repository1 = new TestRepository(new File(workdir, Constants.DOT_GIT));
// now we create a project in repo1
project = testUtils.createProjectInLocalFileSystem(workdir, projectName);
testUtils.addFileToProject(project, "folder1/file1.txt", "Hello world 1");
testUtils.addFileToProject(project, "folder1/file2.txt", "Hello world 2");
repository1.connect(project);
repository1.trackAllFiles(project);
repository1.commit("Initial commit");
File workdir2 = testUtils.createTempDir("Project2");
// Project location is at root of repository
project2 = testUtils.createProjectInLocalFileSystem(workdir2.getParentFile(), "Project2");
testUtils.addFileToProject(project2, "file.txt", "initial");
repository2 = new TestRepository(new File(workdir2, Constants.DOT_GIT));
repository2.connect(project2);
repository2.trackAllFiles(project2);
repository2.commit("Initial commit");
}
use of org.eclipse.egit.core.test.TestRepository in project egit by eclipse.
the class SubmoduleFolderTest method setUp.
@Before
public void setUp() throws Exception {
parentRepositoryGitDir = createProjectAndCommitToRepository();
childRepositoryGitDir = createProjectAndCommitToRepository(CHILDREPO, CHILDPROJECT);
Activator.getDefault().getRepositoryUtil().addConfiguredRepository(parentRepositoryGitDir);
parentRepository = lookupRepository(parentRepositoryGitDir);
childRepository = lookupRepository(childRepositoryGitDir);
parentProject = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJ1);
IFolder folder = parentProject.getFolder(FOLDER);
IFolder subfolder = folder.getFolder(SUBFOLDER);
subfolder.create(false, true, null);
assertTrue(subfolder.exists());
IFile someFile = subfolder.getFile("dummy.txt");
touch(PROJ1, someFile.getProjectRelativePath().toOSString(), "Dummy content");
addAndCommit(someFile, "Commit sub/dummy.txt");
childFolder = subfolder.getFolder(CHILD);
Git.wrap(parentRepository).submoduleAdd().setPath(childFolder.getFullPath().toPortableString()).setURI(childRepository.getDirectory().toURI().toString()).call();
TestRepository parentRepo = new TestRepository(parentRepository);
parentRepo.trackAllFiles(parentProject);
parentRepo.commit("Commit submodule");
assertTrue(SubmoduleWalk.containsGitModulesFile(parentRepository));
parentProject.refreshLocal(IResource.DEPTH_INFINITE, null);
assertTrue(childFolder.exists());
// Let's get rid of the child project imported directly from the child
// repository.
childProject = ResourcesPlugin.getWorkspace().getRoot().getProject(CHILDPROJECT);
childProject.delete(false, true, null);
// Re-import it from the parent repo's submodule!
IFile projectFile = childFolder.getFolder(CHILDPROJECT).getFile(IProjectDescription.DESCRIPTION_FILE_NAME);
assertTrue(projectFile.exists());
ProjectRecord pr = new ProjectRecord(projectFile.getLocation().toFile());
ProjectUtils.createProjects(Collections.singleton(pr), null, null);
assertTrue(childProject.isOpen());
// Now we have a parent repo in a state as if we had recursively
// cloned some remote repo with a submodule and then imported all
// projects. Look up the submodule repository instance through the
// repository cache, so that we get the same instance that EGit
// uses.
subRepository = SubmoduleWalk.getSubmoduleRepository(childFolder.getParent().getLocation().toFile(), CHILD);
assertNotNull(subRepository);
subRepositoryGitDir = subRepository.getDirectory();
subRepository.close();
subRepository = lookupRepository(subRepositoryGitDir);
assertNotNull(subRepository);
}
Aggregations